Show Sidebar

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 .


To get updates and messages, your application has to implement several methods that are used as callback. In C#, they are defined in the IChatClientListener interface.

In our demos, we instantiate and use the ChatClient class to implement the IChatClientListener interface. Once the ChatClient is instantiated you can connect.

Aside AppId, 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.

Continuously call ChatClient.Service() to keep the connection alive and to get incoming messages.

That way you know when to expect new messages.


Public Messages

Prior publishing subscribe the channel you want to publish messages in. Publish messages to all subscribers of a channel with PublishMessage().

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 SendPrivateMessage().


Public Messages

Implement OnGetMessages() on your IChatClientListener interface to handle incoming public messages.

All public messages are automatically cached in Dictionary<string, ChatChannel> PublicChannels, so you don't have to keep track of them. The channel name is the key for PrivateChannels.

In very long or active conversations, you might want to trim each channels history.

Private Messages

To receive and parse private messages you implement OnPrivateMessage().

All private messages are automatically cached in ChatClient.PrivateChannels, so you don't have to keep track of them. Again, a channel name is applied as key for PrivateChannels. Get a (remote) user's channel name with ChatClient.GetPrivateChannelNameByUser(name).

Online Status

Own Status

Set the online status for your players with SetOnlineStatus(). Pass it the actual status and a, optional, status message.

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 an initial update with the current status per friend to OnStatusUpdate() on on your IChatClientListener interface.

 To Document Top