Photon Chat Intro
Get Started
Keep your users communicating while they are online using Photon Chat. Photon Chat applications need a distinct application and AppId to connect to.
Get your AppId from the Chat Dashboard after
free signup
Connect
To get updates and messages, your application has to implement several methods that are used as callback.
Aside AppId, Connect()
is passed the version, an arbitrary string, and the username, a unique name in best case.
Call Service
To keep the connection alive and to get incoming messages continuously call:
Subscribe To Public Channels
With Photon Chat you use public channels to group users or topics. Anyone who subscribes to a public channel gets all messages published within. New channels are created upon first subscription.
Pass an array of strings to Subscribe, for the channels to be subscribed.
Subscribing and unsubscribing will update ChatClient.PublicChannels. Optionally, the ChatChannel instances get the list of subscribers, which updates ChatChannel.Subscribers.
Send
Public Messages
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.
Private Messages
Send a private message to any user with:
Receive
Public Messages
To handle incoming public messages from all subscribed public channels you need a proper chat listener callback:
Private Messages
To receive and parse private messages you implement the following chat listener callback:
Online Status
Own Status
Set the online status for your players and an optional status message with:
Define your own statuses using integers.
Friends Status
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: