Esempio n. 1
0
        void onReceived(string channel_id, string sender, object data)
        {
            if (encoding_ == FunEncoding.kJson)
            {
                string text = json_helper_.GetStringField(data, kMessage);

                lock (chat_channel_lock_)
                {
                    if (chat_channels_.ContainsKey(channel_id))
                    {
                        chat_channels_[channel_id](channel_id, sender, text);
                    }
                }
            }
            else
            {
                FunMulticastMessage mcast_msg = data as FunMulticastMessage;
                FunChatMessage      chat_msg  = FunapiMessage.GetMulticastMessage <FunChatMessage>(mcast_msg, MulticastMessageType.chat);
                if (chat_msg == null)
                {
                    return;
                }

                lock (chat_channel_lock_)
                {
                    if (chat_channels_.ContainsKey(channel_id))
                    {
                        chat_channels_[channel_id](channel_id, sender, chat_msg.text);
                    }
                }
            }
        }
        protected override void onMessageCallback(string channel_id, string user_id, object message)
        {
            if (encoding_ == FunEncoding.kJson)
            {
                string text = json_helper_.GetStringField(message, kMessage);

                base.onMessageCallback(channel_id, user_id, text);
            }
            else
            {
                FunMulticastMessage mcast = message as FunMulticastMessage;
                FunChatMessage      chat  = FunapiMessage.GetMulticastMessage <FunChatMessage>(mcast, MulticastMessageType.chat);
                if (chat == null)
                {
                    return;
                }

                base.onMessageCallback(channel_id, user_id, chat.text);
            }
        }