void Start() { // Gui component. chatGui = this.gameObject.AddComponent("FPSChat"); // 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); // 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); // Join an initial channel. The second argument is a flags string // that sets certain flags on a channel. Currently 'subscribers' is the // one valid option. If subscribers is set, status updates from the server // will include a complete subscriber list for each channel. messenger.joinChannel("global", "subscribers"); // Send this whenever you want a list of subscribed channels, and the optional // subscriber list if you have set the subscribers flag. Remember you get this // automatically when you join/leave a channel. messenger.ChatStatus(); }
void Start() { if (!GamePlayer.IsNetworked()) { Destroy(this.gameObject); return; } canvas = gameObject.GetComponent <Canvas>() as Canvas; canvas.enabled = false; contentHolder = GameObject.Find("chat_text"); messageTemplate = transform.Find("msg_template").gameObject; messageTemplate.SetActive(false); groupContainer = GameObject.Find("group_container"); groupMemberContainer = GameObject.Find("group_member_container"); groupMemberTemplate = GameObject.Find("group_member"); groupMemberTemplate.SetActive(false); groupContainer.SetActive(false); chatInput = GameObject.Find("chat_input").GetComponent <InputField>() as InputField; playerId = GameEntityManager.GetPlayerEntity().GetEntityId(); characterId = GameEntityManager.GetPlayerEntity().GetCharacterId(); messenger = ActorSystem.instance.Find("Messenger") as Messenger; chatCommandHandler = new ChatCommandHandler(messenger, this, playerId); 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); foreach (string channel in autojoinChannels) { messenger.JoinChannel(channel); } InvokeRepeating("UpdateChatStatus", 0.01f, 2.0F); }