Keep your users communicating while they are online using Photon Chat. Photon Chat applications need a distinct application and AppId to connect to.
To get updates and messages, your application has to implement several methods that are used as callback.
Connect() is passed the version, an arbitrary string, and the username, a unique name in best case.
With Photon Chat you use channels to group users or topics. Anyone who subscribes to a channel gets all messages published within. New channels are created upon first subscription.
The subscribe method is passed an array of strings for the channels to be subscribed.
In some SDKs, to keep the connection alive and to get incoming messages continuously call:
That way you know when to expect new messages.
In the latest versions of the C# SDKs this is no longer required.
Prior to publishing subscribe to the channel you want to publish messages in. Publish messages to all subscribers of a channel with:
Other than plain strings Photon Chat allows you to define complex messages, e.g. for invitations.
Send a private message to any user with:
To handle incoming public messages you need a proper chat listener callback:
To receive and parse private messages you implement the following chat listener callback:
Set the online status for your players and an optional status message with:
Define your own statuses using integers.
Just send an array of usernames to Photon to get their future status updates.
You'll receive updates with the current status per friend to the implemented callback: