public void Init(ChatApi chatApi)
{
this.chatApi = chatApi;
// Gui component.
chatbox = this.gameObject.AddComponent<Chatbox>() as Chatbox;
chatbox.CloseChatWindow();
// The messaging actor
messenger = ActorSystem.instance.Find("Messenger") as Messenger;
// Parses the chat language used by the gui and calls messenger
// Feel free to provide your own implementation, this is mostly a starting point.
// Supported syntax is documented in the source
chatCommands = new ChatCommands(messenger, chatbox);
chatCommands.SetChatApi(chatApi);
// Setup callacks so we get notified when we join/leave channels and receive messages
Messenger.ChannelJoined channelCallback = ChannelJoined;
messenger.OnChannelJoined(channelCallback);
Messenger.ChannelLeft channelLeftCallback = ChannelLeft;
messenger.OnChannelLeft(channelLeftCallback);
Messenger.MessageReceived messageCallback = MessageReceived;
messenger.OnMessageReceived(messageCallback);
Messenger.InviteReceived inviteCallback = InviteReceived;
messenger.OnInviteReceived(inviteCallback);
// Send this whenever you want a list of subscribed channels, and the optional
// subscriber list if you have set the subscribers flag. We do it on an interval
// so that you get notified when new players join a group you are in.
// For matchmaking you probably want this value lower so it appears more
// responsive. For mmo type games it could be somewhat higher.
InvokeRepeating("UpdateChatStatus", 0.01f, 5.0F);
}