Client side, Photon is built to give you as much control as possible. This makes sure it integrates well with your game loop.
Disconnects by Client
- Client-side timeout (no/too late acks from server).
- Includes: case if server does not run
- Client socket exception (connection loss)
- Client connection fails on receive (buffer full, connection loss)
- Client connection fails on send (buffer full, connection loss)
- Note: Using localhost, C# raises exceptions even for UDP!
Disconnects by Server
- Server-side timeout (no/too late acks from client)
- Server send buffer full (too many messages)
- License or Subscription CCU limit hit
There are additional cases when client can't connect at all (bad address, no DNS available). In this context, those are not considered disconnects, because there never was a connection.
Keep Calling Service
To include Photon in your client's game loop, you basically just have to call
Regularly means between 10 to 50 times per second (depending on your game / network usage).
Service covers two tasks:
- Received events and data gets executed.
This is done when you can handle the updates.
As a sequence order is always kept intact, everything that the client receives is queued and ordered.
DispatchIncomingCommandsfor this task.
- Outgoing data of your client is sent to the server.
This includes acknowledgments (created in the background) which are important to keep connection to the server.
Service internally calls
SendOutgoingCommandsto do this task. Controlling the frequency of
SendOutgoingCommandscalls controls the number of packages you use to send a client's produced data.
Profiling Service Calls
To detect if you called
Service regularly, we added a statistics module to the client APIs.
If you encounter disconnects, check these values first:
PhotonPeer.TrafficStatsGameLevel track how often you call
SendOutgoingCommands when you turn the stats on (
PhotonPeer.TrafficStatsEnabled = true).
Check the values of
This feature is implemented in C# based libraries currently. More platforms will get this soon.
Platform Specific Info
Photon Unity SDK
If you use our Photon Unity SDK, you probably do the
Service calls in some MonoBehaviour
To make sure Photon client's
SendOutgoingCommands is called while you load scenes, implement a background thread.
This thread should pause 100 or 200 ms between each loop, so it does not take away all performance.