Realtime Intro

Get Started

Photon Realtime is a fully managed service (SaaS) of Photon on-premises servers running in regions worldwide, ready for low latency multiplayer gaming around the globe, anytime.

Use the LoadBalancing API to match players to a shared game session (called "room") and transfer messages synchronously, in real-time, between connected players across platforms. All client SDKs can interact with each other, no matter if iOS, Android, web, console or standalone.

Back To Top


Connect To Photon Cloud

Photon Realtime applications need an AppId to connect to. Get yours from the Realtime Dashboard after free signup.

Simply set your AppId and pick a region to connect to. Click here for a list of available regions.

The C# snippets on this page are not meant for Unity. For everything related to Unity we recommend using PUN 2 the first-class Unity product. Besides, PUN 2 is built on top of the Photon Realtime Unity API. The PUN 2 package contains Photon Realtime Unity SDK.

Back To Top

Connect To Self-hosted Photon Server

Connecting to your self-hosted Photon Server does not require AppId or region. All you need is the server address and port to use with the appropriate connect method of your client.

You can read about the differences between Photon Cloud and Photon Server here especially the "Important Changes Since v4.0.29.11263".

Back To Top

Call Service

The LoadBalancing API is built to integrate well with your game logic. You can fine-control when you want to handle incoming messages and how often you send anything. Internally, both directions are buffered until your game calls LoadBalancingClient.Service().

Games often use a game loop that calculates updates and then refreshes the screen. Call Service() 10 to 50 times per second depending on your game and network usage. If you don't call it, no "network progress" gets done at all.

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. Service internally calls DispatchIncomingCommands to do this task.
  • Outgoing data of your client is sent to the server. This includes acknowledgments (created in the background) which are important to keep the connection to the server. Service internally calls SendOutgoingCommands to do this task. Controlling the frequency of SendOutgoingCommands calls controls the number of packages you use to send a client's produced data.

Back To Top


When the application is quitting or when the user logs out do not forget to disconnect.

Back To Top


Create A Game

To create a new room, aka game, invoke "Create Room" operation on your connected LoadBalancing client.

This sets the room name and amount of players that are allowed in the room. The client will enter the new room automatically. When using the "Create Room" operation the room will be created before joining, if it doesn't exist. Rooms exist until the last player leaves.

You can define "Custom Room Properties" to set shared values for the room when you create it. The custom room properties can be used (e.g.) to store the map name, level or the round duration. The keys of Custom Properties have to be strings. Of course, those values can be set and modified in the room as well.

You can select any of your custom properties to be shown also in the lobby, by setting the optional array with their names as "Custom Room Properties For Lobby". Properties showing in the lobby can be used for matchmaking and as a filter for random matches.

Read more about matchmaking in our guide here.

Back To Top

Find A Game

Clients join games by name or ask Photon to find a perfect match.

Find rooms ...

  • Random: Matches players randomly. Optionally fills rooms or distributes players evenly.
  • Parameterized: Customize random matching by defining lobby properties as filters.
  • Private: Hide rooms and players can only join if they know the room name.
  • Listing: The lobby lists visible rooms to let players pick and join manually.

Back To Top

Persist Games

With Photon Realtime, rooms' data can be saved and loaded easily. You need to set up webhooks to hook up Photon Cloud with an external web server.

Once set up, room states will be saved automatically for you. To rejoin rooms:

This feature makes asynchronous matchmaking and gameplay possible.

Read more about how to do this in our Persistence Guide.

Back To Top


Sending Events

Whatever happens on one client can be sent as an event to update everyone in the same room.

Update your players with stats, positions or your current turn. Photon will send it as fast as possible (with optional reliability).

  • Send messages/events: Send any type of data to other players.
  • Player/Room properties: Photon updates and syncs these, even to players who join later.

Your event codes should stay below 200. Each code should define the type of event and the content it carries.

The event data in the example above is a Hashtable. It can be a byte[] or any data type supported by Photon's serialization (a string, float[], etc.). See Serialization in Photon for more information.

Back To Top

Receiving Events

Whenever an event is dispatched a handler is called. An example is shown below.

Each event carries its code and data in the way your client sent them. Your application knows which content to expect by the code passed (see above).

For an up-to-date list of default event codes look for the event codes constants in your SDK, e.g. within ExitGames.Client.Photon.LoadBalancing.EventCode for C#.

Back To Top

Custom Or Authoritative Server Logic

As is, without authoritative logic, Photon Cloud products already allow for a broad range of game types.

  • First Person Shooters
  • Racing Games
  • Minecraft type of games
  • Casual real-time games
  • Asynchronous and synchronous games
  • ...

Use Photon Server or Photon Plugins to implement your own custom logic.

To Document Top