Photon Sending Events on Scheduled times.
Hello Everyone,
I'm creating a simple multi-player game which extends the Lite Application and arrived in this problem where I need to send an event to all the connected peers on a scheduled time.
Is this possible to do internally with Photon? Can I just install a Cron or Quartz serviced that directly calls a method inside Photon?
If is not can you suggest other alternative solutions?
Yours,
Mark
I'm creating a simple multi-player game which extends the Lite Application and arrived in this problem where I need to send an event to all the connected peers on a scheduled time.
Is this possible to do internally with Photon? Can I just install a Cron or Quartz serviced that directly calls a method inside Photon?
If is not can you suggest other alternative solutions?
Yours,
Mark
0
Comments
-
Use ScheduleOnInterval()0
-
Where can I find an example on how to use it?0
-
I don't think its directly used anywhere but it otherwise works like the regular Schedule thats called in different places0
-
ScheduleOninterval is rarely used.
Instead, we schedule a new message when executing the current one. This way, it's pretty easy to stop scheduling messages.
But like dreamora said: The usage is similar to the regular Schedule. Try it0 -
How do you schedule a new message when executing a new one in a poolfiber?0
-
From LiteLobby (Photon v3):
protected override void ProcessMessage(IMessage message) { // this switch only handles the Lobby-specific messages. // all other messages will be handled by the base class. switch ((LobbyMessageCode)message.Action) { case LobbyMessageCode.PublishChangeList: this.PublishChangeList(); return; // ...
private void PublishChangeList() { if (this.changedRoomList.Count > 0 && this.Actors.Count > 0) { var customEvent = new CustomEvent(0, (byte)LiteLobbyEventCode.GameListUpdate, this.changedRoomList); // PublishEvent(hashtable) uses a reference to hashtable, which means you can not clear it (see below) this.PublishEvent(customEvent, this.Actors, new SendParameters { Unreliable = true }); } this.changedRoomList = new Hashtable(); // creating a new hashtable, as PublishEvent() uses just a ref to the data to be sent this.SchedulePublishChanges(); } private void SchedulePublishChanges() { var message = new RoomMessage((byte)LobbyMessageCode.PublishChangeList); this.schedule = this.ScheduleMessage(message, LobbySettings.Default.LobbyUpdateIntervalMs); }
Hope this helps.0