Chat
ServerBytes chat plugin helps you make your game more social by adding chat features.
This plugin allows public and private channels as well as private messages to other players.
Players can participate in multiple channels. There are no limits on number of channels, messages per channel or players per channel.
This plugin requires Authentication plugin to be installed.
Installation
To add Chat to your game, simply download Unity package and import it into the Unity game, or download Nuget package.
Client
Client setup The very first step to initialize the plugin is to setup the plugin host:
var pluginHost = ClientFactory.GetPluginHost(appKey);
var chatFactory = new ChatFactory(pluginHost);
// instantiate other plugins,
// create the client
var client = ClientFactory.GetClient(pluginHost);
Client.OnConnected += Client_OnConnected;
Client.OnFailedToConnect += Client_OnFailedToConnect;
Client.OnDisconnected += Client_OnDisconnected;
Client.Connect();
Read more about installation here
Once the plugin is registered, and the client is connected, we can start using chat.
Note: The player must be authenticated before using chat.
private void Client_OnConnected()
{
IChatService chatService = chatFactory.Create(Client);
}
To start using chat plugins, read more about channels here.
Glossary
Type | Description |
---|---|
Channel | Base class for channels. |
ChannelInfo | Contains metadata for a channel. |
ChatPlayerInfo | Provides methods for adding or updating documents. |
ListChannelsQuery | Provides methods for managing and querying documents for specified collection. |
PrivateMessageClient | Base class for private messaging. |
IChatService | Provides methods for listing collections. |