Event sequencing with Photon Cloud

Hi, I'm sorry if this is the wrong forum but Turnbased was the closest fit I could find for Realtime or Cloud.

I have developed a library for networking RTS/MOBA style games in Unity, and would like to add backend support for Photon Cloud. The most important function of the server in an RTS game is to ensure consistent message sequencing between the players, so that they all agree on what order commands were issued in.

I'd like to know whether Photon Realtime makes any guarantees about the order in which events are processed on connected clients. For example, with a group of 10 clients, if client A sends an event to the server, and client B sends another event, these events arrive at the server in some order, and the server relays them to all 10 connected clients. Is the order in which the clients process these events deterministic?

If not, is there any solution using any Photon Cloud system that would guarantee the order, or at least put a sequence number in the relayed events so that the clients themselves can perform the sorting? Maybe Photon Chat would work better here?

Normally I would write a small piece of generic server-side code to manage this, an this works well with Player.IO, but with Photon I'm trying to avoid that as I'd like users of my library to have the option of using a Photon Cloud, which does not support server-side plugins except on high-tier subscriptions.

Comments

  • A framework for RTS/MOBA? Sounds cool! I think quite some developers might be interested in that.

    We don't make order-guarantees for messages sent by clients at about the same time. There is no time-based sequencing and the order is simply "time of dispatching" on the server side. This means that a delayed package can make the difference of being "right on time" or "being too late".

    The order of events we sent is fixed when the server creates the events for the clients. So, per room, the outgoing order is fixed. Unreliable events might be dropped out of that order but reliable ones keep their sequence.
    Keep in mind, that Photon has a lower-level concept of "eNet Channels": Each channel defines an independent sequence. This can be interesting if you have 2 or more independent event-sequences (chat and position updates) which you want to decouple.

    Photon Chat has the same principles, so that won't help.

    How do you determine the sequence of events in the first place? When players act more or less at the same time, you will have to define some order, right? If that order is "made up", then maybe a bit of lag is not a problem?
    The negative side of Photon's system is that one player can be affected by his own lag. On the other hand, the others don't suffer from someone's slow connection.

    Do you want to build a deterministic lock-step system?
  • Yes, I have a deterministic lock-step engine working on some other backends and I'd like to port it to Photon Cloud. I'm also targeting Photon Server of course, but that one is easy as I can just write custom server-side code :)

    Thanks for the answers Tobias, it sounds like it should work. The sequence of events is kind of arbitrary - the important thing is that the server somehow defines a sequence and sends the same sequence to all the clients.

    It is still not ideal though, as with custom server code the system can have lower bandwidth requirements and be more cheat-proof. Do you have any plans to allow use of simple server-side plugins on Photon Cloud? Yahoo GamesNet support this, and it was very easy for me to integrate support for that, it only took about a day. They have plenty of restrictions on what your code can do, of course!

    Simply being able to configure the server to emit a time signal at regular intervals (e.g. 500ms) would be useful too.
  • We are experimenting with plugins for the Photon Cloud but so far, this is restricted to the "Private Cloud" variant. It's semi-public for bigger projects. Potentially, we could give you access to the "Server Plugin SDK", so you could offer a server side solution, too.
    Aside from that, we don't run custom code which we don't know in and out.

    The pointer to Yahoo GamesNet is interesting. Maybe we can come up with some restrictions (and automated checks) which are similar to theirs. We'll look into their solution.

    You can't send a signal every 500ms but you could probably use our low-level server timestamp for something similar. The idea is that we sync the timestamp of the server to all clients. They extrapolate the time locally to keep up to date. With only +/-20 ms difference between clients, that time is more or less synchronous on clients in one room.

    Look into LoadBalancingPeer.ServerTimeInMilliSeconds and let me know if you can make use of that.
  • Thanks Tobias, that is interesting but I don't think it helps. I need a client to be able to determine that the server's time has passed a certain point, and that all messages sent by the server before that point have been received. "More or less" doesn't really work with deterministic simulations. :(

    The only way I know to make this happen on Photon Cloud at the moment is to send periodic messages from one of the clients, to form the clock pulse, then rely on the message ordering as we discussed before. This generates a lot of unnecessary network traffic though, and I don't see a good way to protect against client hacks compromising the clock pulse.

    I think for now I will aim to support only Photon Server.
  • Sorry for the late reply. I was on vacation and basically offline.

    You are right about the turn-ending notice, I guess.
    It's probably not feasible to make every client send a turn all the time, even if nothing happened. Just to get "turns" done.