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 .

Connect

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.

Subscribe

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.

Send

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

Receive

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.

Get Support

We, the Photon Team ( sometimes referred to as Photonians :), are dedicated to help you. If you've got questions, curiosities, ... or your app doesn't work but you really wish it would, try any of these:

Get It Faster

For quick turn-arounds please include, together with reproducible steps:

  • Photon Client SDK version
    • This is part of the SDK zip file name.
    • In case of PUN send us the value of: PhotonNetwork.versionPun.
  • Photon Cloud
    • Drop us the AppId and the Game Version which is set via Connect*() call.
    • If you have trouble with some room, send us the RoomName and the Server Address of it. In C#, log client.CurrentServerAddress while in the room
    • Let us know the Region and the Server Address.
  • Photon Server
    • Hosting a Server? Let us know the Server SDK Version. Again, this is part of the SDK zip file name.
    • Add your logs.

Get in Touch

We'd love to know what you want to read and see in our docs, whether that is more demos, specific documentation, an FAQ or example applications. If there's something you'd like to see that's not already in drop us your suggestion to developer@photonengine.com.

Want to learn more about Photon?

Get started, Try Free Plan
Find us at these events and venues.
Request a meeting.

 To Document Top