PhotonPeer service call

Options
KevinB
KevinB
edited September 2012 in Photon Server
From the doc, it said we should call the service call regularly like 10 times a second something like that otherwise it could lead to timeout disconnect. This confuses me. It sounds pretty much like a polling base system rather than event driven one.

Our multi player board game probably won't generate many events within a second for each individual client. Do we still need to call service call multiple times a second? This definitely eats up a lot of bandwidth, and for our game, we are expecting only 1 event every couple of seconds.

How does the service call work exactly? do operations and events piggyback on such call? or it's just purely for maintaining connection?

Thanks in advance.

K

Comments

  • Kaiserludi
    Options
    Photon Clients (except the Flash clients, which do not provide service(), not sure out of my head about the Javascript ones) do not actually send the data,that you have passed to them or pass received data to the callbacks until you call the according API functions sendOutgoingCommands() and dispatchIncomingCommands(). This is for giving you more flexibility and performance: If one is creating several small operations between 2 sendOutgoingCommands()-calls, then they will end up in the same udp packet and this way the overhead for the packet header will just have to be sent once for all of them. Sending out every created operation immediately can have negative impacts on network performance, if on is for example creating several operations in the same frame. Additionally one can decide to just send out commands and not dispatch any incoming ones yet, when one for example is in a loading screen, etc.
    service() is just a convenience method, that calls sendOutgoingCommands() and (in a loop) dispatchIncomingCommands() (and also calls serviceBasic() for C++ and objC clients).
    If you are not creating any operations for some time, then sendOutgoingCommands() will create a ping command on its own, which just tells the server, that your client is still alive. Without calls to sendOutgoingCommands() neither your own operations nor these pings will ever reach the server, so it will assume, that your client has lost its connection.
  • KevinB
    Options
    Thanks.

    so what's the min frequency of pinging the server in order to keep its connection? I don't seem to see such a number in the doc. and it seems that there's no source code for service() call?

    and from the architecture point of view, why does it use such pinging method to maintain connection? can the server assume client lost the connection only when client doesn't respond to server msg/request(instead of the frequent pinging)? just curious about the tradeoff here.

    K


    K