Game simulation on server

edited December 2010 in Photon Server
How can I simulate a game on the server?
I need to simulate the game on server as clients need to be only viewers that send input to server and server checks input and sends back events to clients.
What is the way to organize a game loop?


  • Boris
    I would use a Channel to broadcast the events, have the peer fibers subscribe.
    You can use a PoolFiber to schedule your game logic tasks.
  • So just schedule my update loop for example every 50 ms and just subscribe peers to its events?
  • Tobias
    Yes. That would trigger a function in every peer, so they can do their independent (of each other) simulations.
    If your simulation changes values across several peers, you should probably schedule the update message for your room, calculate changes and then broadcast the outcome to the individual peers of the room.
  • Just not to create a new theread two small questions:
    1) ScheduleOnInterval(action, firstinms, regularinms)
    What do the two longs mean exactly?
    As I can guess the action will be executed after "firstinms" last and then continue to execute every "regularinms"?
    If so how do I cancel this event?
    2) SetCurrentOperationHandler method will just route my request from peer's OnOperationRequest to the implementation of IOperationHandler?
  • Boris
    1) correct; scheduleOnInterval returns an Idisposable that you can dispose to stop future execution.
    2) correct