Photon Chat

The Photon Chat plugin is specifically to implement a dedicated chat connection for multiplayer games through the Photon Engine and PlayFab, for games built using Construct 3 and Construct 2.


It is a fork or improvement from the official Photon plugins, although additions and changes are gradually added and appended, including PlayFab integration, where a dedicated chat system is integrated with an account management and networking system.


The Photon Chat plugin has full PlayFab integration, taking advantage of all features from the PlayFab Master Collection. This integration creates a unified and complete chat features for turnbased, realtime and massive online multiplayer, from simple to highly advanced games.

PlayFab API v2.png

Introduction

Step 1.png

The Construct Master Collection supports the full and easy integration of the PlayFab service for both Construct 3 and Construct 2.


Please click here to learn more about PlayFab.

Features


Here are some of the features of the PlayFab service:

  • Dedicated chat system

  • World chat

  • Game chat

  • Private messaging

  • Realtime messaging

  • Massive online multiplayer

  • Turn based multiplayer

  • Account system integration

  • Account management

  • Profile management

  • Social connect

  • Friend management

  • Cloud script and functions

  • Webhooks

  • Chat channels

  • User chat status

  • Chat caching system

  • Multiple region support

  • Security features with server scripting.

  • Organized request and update features.


For more information about all the integrated PlayFab service features, please click here to learn the introductory lessons to PlayFab.


Network Services


Here are some of the platform services that can be linked:

  • PlayFab

  • Google Play

  • Game Center

  • Facebook

  • Facebook Instant Games

  • Steam

  • Xbox Live

  • Instant Games (Android Studio port)

  • Nintendo Switch (3rd party porting services)

  • PS4 (3rd party porting services)

  • Nintendo Switch (3rd party porting services)


Editor Features


Here are some of the features in the Construct editor:

  • All platforms support, including web, mobile and desktop.

  • Construct 3

  • Construct 2

 
 

How to use?

It is easy to use the Photon Chat plugin, you will only need to follow the steps below.

  1. Set up the PlayFab API plugin, please click to visit the documentation. This includes creating a PlayFab account, studio and title.

  2. Set up the Authentication plugin, please click to visit the documentation.

  3. Finally, you can now use the Photon Chat object, and include more PlayFab addons for more features.

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



5. Retrieve the App ID of your chat application, labeled below.

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



7. Set your AppVersion, preferably similar to your game application's version. Only users with the same app version will be able to play together.

8. If you are using Construct 2, set the protocol to ws since preview is ran locally, However, if you are using Construct 3, then use the wss protocol.

9. Set the target Region of application.

We have a sample Cloud Script implementation for this feature, click here.


10. Lastly, set the Log Level you want Photon Chat to use.

 
 

Documentation

There is currently nothing to show, we will add more in the future.



PlayFab Server Setup


PlayFab server-side integration with Photon Chat is quick and easy. To get started you need to create both a PlayFab and Photon Engine account. Once you have both accounts, you need to create a title (game) in any studio of your PlayFab account. Then, create a Photon Chat game application project in your Photon Engine account.

Afterwards, proceed below and the guide will walk you through the process of setting up your PlayFab and Photon Chat integration.



Step 1 : From the PlayFab Dashboard, select the Add-ons menu option. It will show the item group of PlayFab partner services. Select Photon in the Multiplayer addons group.



Step 2 : PlayFab's Photon Cloud integration description will show, please read this first and then proceed to the next step after you are done.



Step 3 : Install the Photon addon if not yet installed, then fill the credential forms if there are any. Required credentials are needed to link your PlayFab title (game) and your Photon Chat game application project, to initiate full integration.


Step 4 : Take note of the Photon Secret key and input your Photon Chat App ID. This is the same App ID you've inputted in the Photon Chat plugin from Construct 3 or Construct 2.



Step 5 : You are almost done in completely integrating your PlayFab title (game) with your Photon Chat game application project. You just need to follow the instructions in the image to configure your Photon Console.



Step 6 : You have now finished your PlayFab and Photon Chat integration setup. For more optional features, please proceed below.


Step 7 : There is also an optional feature called Photon Webhooks and WebRPC with the PlayFab integration. This feature allows you to extend Photon with PlayFab's automation features including scripting, scheduled tasks and rules. Listening to Photon events while the game is running allows you to run scripts during the game session. PlayFab being a complete network system with account management features allows you to reflect their game session data automatically into their account, statistics and leaderboards, and the analytics, global data and system. This is one of the reasons why PlayFab integration with Photon Cloud is highly advantageous for developers to implement realtime multiplayer games with automation and scripting that transforms the Photon Chat from a dedicated chat network to a complete chat network system, with account management features.



Related Plugins


  • Photon Realtime - is a plugin that implements a realtime multiplayer sync feature for your game applications, this transmits and receives data faster than what chat messaging requires, ideal for syncing important game details. While the Photon Chat is the plugin that syncs game chat data on a separate dedicated connection ideal for messaging.



Scripting Interface


The Photon Chat has basic support for Construct 3's scripting feature. Click to learn more about the scripting feature. Also, check out Photon's official documentation to take advantage of all its features.

  • Context - Returns the Photon Chat's instance context. Example: const self = runtime.objects.PhotonChat.getFirstInstance().Context;

  • Client - Returns the Photon Chat instance's load balancing client. Example: const ChatClient = runtime.objects.PhotonChat.getFirstInstance().Client;

  • Photon - Returns the global Photon object. Example: const Photon = runtime.objects.PhotonChat.getFirstInstance().Photon;

For the complete guide and API documentation, please click to visit the full documentation.

 

Actions, Conditions & Expressions

Actions

press to zoom

press to zoom
1/1

The following action groups:

  • Connection

  • Chat

  • Common

  • PlayFab

Connection

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

  • UserId - User id.


  • Set custom authentication - Enable custom authentication and set it's parameters.

  • AuthParameters - Parameters expected by the used authentication service.

  • AuthType - The type of custom authentication provider that should be used.


  • 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.

Chat

  • Subscribe - Subscribe to channels.

  • Channels - Comma-separated list of channels.

  • History - Controls messages history sent on subscription. 0: no history. 1 and higher: number of messages in history. -1: all history.

  • LastIds - Comma-separated list of last messages IDs.

  • Unsubscribe - Unsubscribe from channels.

  • Channels - Comma-separated list of channels.

  • Publish message - Send message to a public channel.

  • Channel - Channel name.

  • Message - Message.


  • Send private message - Send private message to a single target user.

  • UserId - User id.

  • Message - Message.

  • Add friends - Add entries to the list of users sending you status updates.

  • UserIds - Comma-separated list of user ids.


  • Remove friends - Remove entries from the list of users sending you status updates.

  • UserIds - Comma-separated list of user ids.


  • Set user status - Set user's status and an optional message.

  • Status - Status

  • Custom Status - Custom Status

  • Message Option - Status message option.

  • Message - Status message.


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

The following condition groups:

  • Connection

  • Chat

  • PlayFab

  • Client

press to zoom

press to zoom
1/1

Connection

  • On connected to Front End - Triggered when client connects to Front End and ready to chat.

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

  • Is connected to Front End - True if client connected to Front End server.



Chat

  • On message in channel - Triggered on new message in specified channel.

  • Channel - Channel name.


  • On message - Triggered on new message in any channel.

  • On private message in channel - Triggered on new message in specified private channel.

  • Channel - Channel name.


  • On private message - Triggered on new message in any private channel.

  • On user status update - Triggered when friend changed his status.

  • On subscribe result - Triggered when result of subscription request received.

  • Success - Channel subscription result.

  • On unsubscribe result - Triggered when result of unsubscription request received.

  • Success - Channel unsubscription result.


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.

Expressions

press to zoom

press to zoom
1/1

The following expression groups:

  • Connection

  • Chat

  • PlayFab

  • Client

Connection

  • State - Current client state.

  • StateString - Current client state string.

  • UserId - Previously set user id.



Chat

  • Channel - Channel name set in last condition.

  • Message - Message set in last condition.

  • Sender - Sender set in last condition.

  • UserStatusUserId - Id of user which status was last updated.

  • UserStatus - Last updated user status.

  • UserStatusString - Message sent along with last user status update.

  • UserStatusMessageUpdated - True is message was sent along with last user status update.

  • UserStatusMessage - Message sent along with last user status update.

  • ChannelLastMessageID - Channel last message ID.

  • Channel - Channel name.


PlayFab

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

Client

  • ErrorCode - Last error code.

  • ErrorMessage - Last error message.

Object   Properties

Plugin Properties

press to zoom

press to zoom
1/1

The following properties groups:

  • Default

  • App Id - Application id.

  • App Version - Application version.

  • Protocol - Connection protocol.

  • ws

  • wss

  • Region - Master server region.

  • EU

  • US

  • Asia

  • Log Level - Logging level.

  • DEBUG

  • INFO

  • WARN

  • ERROR

  • OFF

 
 

Showcase

There is currently nothing to show, we will add more in the future.

 

Game Projects 

Instructions Kit

Construct 3 Project
Construct 3 Project

press to zoom
Construct 2 Project
Construct 2 Project

press to zoom
Construct 3 Project
Construct 3 Project

press to zoom
1/2

Specifications

  • Instructions - The game project contains instructions and steps on how to use the addon and its features.

  • Action, Conditions and Expressions - It covers the implementation of each action, condition and expression.

  • Tips and Tricks - It provides some tips and tricks on the recommended ways of using the addon.

Supporters

Only