Photon Realtime

The Photon Realtime is a multiplayer addon, it implements matchmaking to the actual gameplay data syncing.

It is a fork from the official Photon addon, although improvements are gradually added, including the PlayFab integration, where it becomes from a multiplayer plugin into a full fledged networking system.

This has full PlayFab integration, taking advantage of all features from the PlayFab Master Collection. 

 

This integration makes the Photon Realtime complete.

 

Intstructions

1. The first step is to add the PlayFab API addon into the project.

2. Then, add the Authentication addon into the project.

3. Finally, add the Photon Realtime addon into the project.

4. To start the Photon Realtime, create an account on Photon Engine. Then, create a Photon Realtime application.

5. Get the App ID of your realtime application, labeled below.

6. Once you have the App ID, input it into the AppId property of the Photon Realtime.

7. Set your AppVersion, preferably similar to your game application version.

8. If you are using Construct 2, set the protocol to ws since it's ran locally, but if you are using Construct 3, then use the wss protocol.

9. Set the Region to the region of the application you will be releasing that specific application release, it's preferable if you release different application releases for different regions, especially on mobile.

For web, you can either release different states per region or just set this automatically through events. But, technically, you can still do it however you want.

10. Set HostType to Photon Cloud, if you don't use use Photon On-Premise.

11. If self-hosted through On-Premise, set the server hosting address.

12Lastly, set the Log Level you want Photon Realtime to use.

Actions, Conditions & Expressions

Actions

Connection :

  • Set user id - Set optional user id (required by some cloud services).

    • UserId - User id.

​​

  • Set hosting type - Set hosting type.

    • HostType - Choose hosting type.

  • Set Self Hosted address - Set Self Hosted address.

    • SelfHostedAddress - Self Hosted address.

  • Set region - Set Master server region.

    • Region - Region.

  • Set app id - Set app id.

    • App id - App id.

  • Set app version - Set app version.

    • App version - App version.

  • Connect - Connect to the name server.

  • Disconnect - Disconnect from all servers.

  • Suspend room - Disconnect client from Game server keeping player in room (to rejoin later) and connect to Master server if not connected.

  • Leave room - Leave room and connect to Master server if not connected.

Lobby :

  • Create room - Create room.

    • Room - Room name.

    • LobbyName - Lobby name.

    • LobbyType - Lobby type.

  • Join room - Join room.

    • Room - Room name.

    • Rejoin - Rejoin by current userId

    • CreateIfNotExists - Create room if it does not exist

    • LobbyName - Lobby name.

    • LobbyType - Lobby type.

  • Join random room - Join random room.

    • MatchMyRoom - Use my room MaxPlayer and custom properties for matchmaking.

    • MatchmakingMode - Matchmaking mode

    • LobbyName - Lobby name.

    • LobbyType - Lobby type.

    • SqlLobbyFilter - SqlLobby filter.

  • Find friends - Request Master server for friends online status and joined rooms (FindFriends).

    • Friends - Comma-separated list of friends user id's

  • Request lobby stats - Request Master server for lobbies statistics.

 


Room :

  • Raise event - Raise game event.

    • Code - Identifies this type of event.

    • Data - Custom data you want to send along.

    • InterestGroup - The ID of the interest group this event goes to.

    • Cache - Caching options for events.

    • Receivers - Defines to which group of players the event is passed on.

    • TargetActors - Comma-separated list of target actors (who should receive the event) id's. Use only for small target groups. Send to all if empty.

    • WebForward - Forward to web hook.

  • Change groups - Change client's interest group.

    • Action - Group action.

    • Group - Group to add or remove.

  • Set property of my room - Set custom property of my room.

    • PropName - Property Name.

    • Value - Property value.

    • WebForward - Forward to web hook.

    • CheckAndSet - Set only if old equals to expected.

    • ExpectedValue - Expected property value.

  • Set props listed in lobby - Set properties listed in lobby.

    • PropNames - Comma-separated list of properties mames to be listed in lobby.

  • Set my room is visible - Set rooms visibility in the lobby's room list.

    • IsVisible - New visibility value.

  • Set my room is open - Set if this room can be joined.

    • IsOpen - New property value.

  • Set my room max players - Set max players before room is considered full.

    • MaxPlayers - New max players value.

  • Set empty room live time - Set room live time in the server room cache after all clients have left the room.

    • EmptyRoomLiveTime - New live time value in ms.

  • Set suspended player live time - Set time in ms indicating how long suspended player will be kept in the room.

    • SuspendedPlayerLiveTime - New live time value in ms.

  • Set unique userid check - Activates user id checks on joining if set to true.

    • Unique - New property value.


Lobby & Room :

  • Call WebRpc - Call remote procedure (WebRPC).

    • UriPath - Remote procedure uri path.

    • Parameters - Remote procedure parameters.

    • ParametersType - Parameters type.


Actor :

  • Set my actor name - Set name of local actor.

    • name - Actor name.

  • Set property of actor by nr - Set custom property of actor.

    • ActorNr - Actor number.

    • PropName - Property Name.

    • Value - Property value.

    • WebForward - Forward to web hook.

    • CheckAndSet - Set only if old equals to expected.

    • ExpectedValue - Expected property value.


Common :

  • Reset - Disconnects and creates new client instance.


PlayFab :

  • PlayFab Authenticate - Authenticate with PlayFab. A variety of custom authentication.

    • PlayFab ID - The PlayFab ID you can get from the PlayFab Master Collection.

    • Photon Token - The PlayFab Photon Token you can get from the "Get Photon Token" action.

  • Get Photon Token - Gets a Photon custom authentication token that can be used to securely join the player into a Photon room.

Conditions

Connection :

  • Is connected to Nameserver - True if client connected to Nameserver.

  • Is connected to Master server - True if client connected to Master server.

  • Is connected to a lobby - True if client connected to a lobby.

  • Is joined to a room - True if client joined to a room.

Lobby :

  • On room list - Triggered on room list receive.

  • On room list update - Triggered on room list update.

  • On FindFriends result - Triggered when FindFriends request completed.

  • On lobbies statistics update - Triggered when lobbies statistics update received.

  • On application statistics update - Triggered when application statistics update received.

  • On join lobby - Triggered on client joins lobby.

  • On joinRandomRoom no match found - Triggered when joinRandomRoom called and no match found.


Room :

  • On event - Triggered on custom event with specific code.

    • Code - Event code.

  • On any event - Triggered on any custom event.

  • On actor properties change - Triggered when actor properties changed.

  • On my room properties change - Triggered when my room properties changed.

  • On join room - Triggered when client joins room.

  • On actor join - Triggered when new actor joins the room.

  • On actor leave - Triggered when actor leaves the room.

  • On actor suspend - Triggered when actor suspended in the room.


Lobby & Room :

  • On WebRPC result - Triggered when WebRPC request completed.


PlayFab :

  • On Get Photon Token - Triggers when the request to get the photon authentication token has succeeded.

 

  • On Get Photon Token Failed - Triggers when the request to get the photon authentication token has failed.


Client :

  • On error - Triggered on error.

  • On state change - Triggered on client state change.

  • On disconnect - Triggered when client gets disconnected from all servers.

Expressions

Connection :

  • State - Current client state.

  • StateString - Current client state string.

  • UserId - Previously set user id.

Lobby :

  • MyRoomName - Currently my room name.

  • RoomCount - Count of rooms available.

  • RoomNameAt - Name of room at index.

    • Index - Room index.

  • RoomMaxPlayers - Max players before room is considered full

    • Name - Room name.

  • RoomIsOpen - Defines if this room can be joined.

    • Name - Room name.

  • RoomPlayerCount - Count of player currently in room.

    • Name - Room name.

  • RoomProperty - Room property.

    • Name - Room name.

    • PropName - Property name.

  • FriendOnline - True if friend is online.

    • Name - Friend name.

  • FriendRoom - Currently joined room name or empyt string.

    • Name - Friend name.

  • LobbyStatsCount - Count of lobbies statistics entries.

  • LobbyStatsNameAt - Lobby name.

    • Index - Lobby index.

  • LobbyStatsTypeAt - Lobby type.

    • Index - Lobby index.

  • LobbyStatsPeerCountAt - Number of players in the lobby (on Master, not playing).

    • Index - Lobby index.

  • LobbyStatsGameCountAt - Number of games in the lobby.

    • Index - Lobby index.

  • AppStatsPeerCount - Count of players currently online on Game servers.

  • AppStatsMasterPeerCount - Count of players on Master server (looking for game).

  • AppStatsGameCount - Count of games currently in use (includes invisible and full rooms, so it doesn't match lobby list).


Room :

  • MyActorNr - Local actor number.

  • EventCode - Last Photon event code.

  • EventData - Last Photon event data.

  • ActorNr - Actor number.

  • PropertyOfMyRoom - Property of my room.

    • PropName - Property name.

  • ActorCount - Count of actors in room.

  • ActorNrAt - Actor number of actor at index.

    • Index - Actor index.

  • ActorNameByNr - Name of actor by number.

    • Index - Actor index.

  • PropertyOfActorByNr - Property of actor by number.

    • ActorNr - Actor number.

    • PropName - Property name

  • ChangedPropertiesCount - Changed properties count.

  • ChangedPropertyNameAt - Changed property name at index.

    • Index - Property index.

  • MasterActorNr - Actor number of room master.

  • WebRpcUriPath - Request path of WrbRpc which triggered OnWebRpc condition.

  • WebRpcResultCode - Result code returned by remote procedure.

  • WebRpcData - Data returned by remote procedure.


PlayFab :

  • PhotonToken - Return the "Photon Token" on "Get Photon Token".


Client :

  • ErrorCode - Last error code.

  • ErrorMessage - Last error message.

Properties

  • AppId - Application id.

  • AppVersion - Application version.

  • Protocol - Connection protocol.

    • ws

    • wss

  • Region - Master server region.

    • eu

    • us

    • asia

    • jp

    • au

    • usw

    • sa

    • cae

    • kr

    • in

    • cn

    • ru

    • rue

  • HostType - Hosting type.

    • Photon Cloud

    • Self Hosted

  • SelfHostedAddress - Self Hosted server address.

  • LogLevel - Logging level.

    • DEBUG

    • INFO

    • WARN

    • ERROR

    • OFF

PlayFab Server Setup

The PlayFab's server side integration with the Photon Realtime is fairly easy. You just need to have both a PlayFab account and Photon account, which you should already have. And have an application for both services you want to connect. Then the instructions below will walk-through  you to the process.

Addons.png
Photon - PlayFab Addon.png

Step 1 : From the PlayFab Dashboard, select the Add-ons menu option. It will show the lists of PlayFab's partner services. Select Photon from the Multiplayer addons list.

PlayFab Photon Integration - 1.png

Step 2 : The PlayFab's Photon addon integration description will show, please read this, then after proceed to scroll down.

PlayFab Photon Integration - 2.png

Step 3 : Install the PlayFab addon if it's not yet installed, fill the forms if there are any.

Step 4 : Take note of the Photon Secret key and input your Photon Realtime App ID. This is the same App ID you've inputted in the Photon Realtime addon from Construct.

Realtime - Setup.png

Step 5 : You are almost done, just follow these instructions to configure from your Photon Console.

Step 6 : You are now done! But for more features, proceed below.

Step 7 : Lastly, there is an optional feature called Realtime Webhooks And WebRPC that is also one of the reason PlayFab integration with Photon transforms the Photon feature from a multiplayer plugin to a complete network system solution.

That's it for this setup guide, enjoy your new game features and happy game development!

PlayFab Integration Project

Sample Setup Project

Specifications

  • Instructions - The sample project has comments and instructions on how to use the addon and its features.

  • A.C.E. Coverage - It covers the implementation of each action, condition and expression.

  • Tips and Tricks - It provides some tips and tricks to a better use of the addon and of the event-sheet system alongside it.

Supporters

Only

Demo Chat

Sample Setup Project

Specifications

  • Instructions - The sample project has comments and instructions on how to use the addon and its features.

  • A.C.E. Coverage - It covers the implementation of each action, condition and expression.

  • Tips and Tricks - It provides some tips and tricks to a better use of the addon and of the event-sheet system alongside it.

Supporters

Only

Demo Pool

Sample Setup Project

Specifications

  • Instructions - The sample project has comments and instructions on how to use the addon and its features.

  • A.C.E. Coverage - It covers the implementation of each action, condition and expression.

  • Tips and Tricks - It provides some tips and tricks to a better use of the addon and of the event-sheet system alongside it.

Supporters

Only

Demo Test

Sample Setup Project

Specifications

  • Instructions - The sample project has comments and instructions on how to use the addon and its features.

  • A.C.E. Coverage - It covers the implementation of each action, condition and expression.

  • Tips and Tricks - It provides some tips and tricks to a better use of the addon and of the event-sheet system alongside it.

Supporters

Only

Photon Chat

The Photon Realtime implements the dedicated realtime sync of game data, this communication traffic must remain dedicated for game data sync where speed is an upmost priority, to get the optimum performance results. A reason to make a dedicated connection for game chats, hence the Photon Chat addon.

 
 
 
 
 

Get the tools

for your pro games!

Constuct Master Collection - Itch.io
Constuct Master Collection - Discord
Constuct Master Collection - Construct 3

© Construct Master Collection 2020 • All rights reserved

Contact Information: