예제 #1
0
        void IChatCallbacks.ChatChannelMessageCallback(ChatMessageList messageList)
        {
            for (int i = 0; i < messageList.Messages.Length; ++i)
            {
                m_Messages.AddLast(messageList.Messages[i]);
            }

            try
            {
                if (m_UseEmoticons)
                {
                    if (TokenizedMessagesReceived != null)
                    {
                        List <ChatTokenizedMessage> list = new List <ChatTokenizedMessage>();
                        for (int i = 0; i < messageList.Messages.Length; ++i)
                        {
                            ChatTokenizedMessage tokenized = null;
                            ErrorCode            ret       = m_Chat.TokenizeMessage(messageList.Messages[i], out tokenized);
                            if (Error.Failed(ret) || tokenized == null)
                            {
                                string err = Error.GetString(ret);
                                ReportError(string.Format("Error disconnecting: {0}", err));
                            }
                            else
                            {
                                list.Add(tokenized);
                            }
                        }

                        ChatTokenizedMessage[] arr = list.ToArray();

                        this.TokenizedMessagesReceived(arr);
                    }
                }
                else
                {
                    if (RawMessagesReceived != null)
                    {
                        this.RawMessagesReceived(messageList.Messages);
                    }
                }
            }
            catch
            {
            }

            // cap the number of messages cached
            while (m_Messages.Count > m_MessageHistorySize)
            {
                m_Messages.RemoveFirst();
            }
        }
예제 #2
0
    protected void HandleTokenizedMessagesReceived(string channelName, ChatTokenizedMessage[] messages)
    {
        if (DebugOverlay.InstanceExists)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < messages.Length; ++i)
            {
                ChatTokenizedMessage msg = messages[i];
                sb.Append("    <").Append(channelName).Append("> ").Append(msg.DisplayName).Append(": ");

                for (int t = 0; t < msg.Tokens.Length; ++t)
                {
                    ChatMessageToken token = msg.Tokens[t];
                    switch (token.Type)
                    {
                    case TTV_ChatMessageTokenType.TTV_CHAT_MSGTOKEN_TEXT:
                    {
                        ChatTextMessageToken mt = (ChatTextMessageToken)token;
                        sb.Append(mt.Message);
                        break;
                    }

                    case TTV_ChatMessageTokenType.TTV_CHAT_MSGTOKEN_TEXTURE_IMAGE:
                    {
                        ChatTextureImageMessageToken mt = (ChatTextureImageMessageToken)token;
                        sb.Append(String.Format("[{0},{1},{2},{3},{4}]", mt.SheetIndex, mt.X1, mt.Y1, mt.X2, mt.Y2));
                        break;
                    }

                    case TTV_ChatMessageTokenType.TTV_CHAT_MSGTOKEN_URL_IMAGE:
                    {
                        ChatUrlImageMessageToken mt = (ChatUrlImageMessageToken)token;
                        sb.Append("[").Append(mt.Url).Append("]");
                        break;
                    }
                    }
                }

                DebugOverlay.Instance.AddViewportText(sb.ToString());
                sb.Remove(0, sb.Length);
            }
        }
    }
예제 #3
0
    protected void HandleTokenizedMessagesReceived(string channelName, ChatTokenizedMessage[] messages)
    {
        if (DebugOverlay.InstanceExists)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < messages.Length; ++i)
            {
                ChatTokenizedMessage msg = messages[i];
                sb.Append("    <").Append(channelName).Append("> ").Append(msg.DisplayName).Append(": ");

                for (int t = 0; t < msg.Tokens.Length; ++t)
                {
                    ChatMessageToken token = msg.Tokens[t];
                    switch (token.Type)
                    {
                        case TTV_ChatMessageTokenType.TTV_CHAT_MSGTOKEN_TEXT:
                            {
                                ChatTextMessageToken mt = (ChatTextMessageToken)token;
                                sb.Append(mt.Message);
                                break;
                            }
                        case TTV_ChatMessageTokenType.TTV_CHAT_MSGTOKEN_TEXTURE_IMAGE:
                            {
                                ChatTextureImageMessageToken mt = (ChatTextureImageMessageToken)token;
                                sb.Append(String.Format("[{0},{1},{2},{3},{4}]", mt.SheetIndex, mt.X1, mt.Y1, mt.X2, mt.Y2));
                                break;
                            }
                        case TTV_ChatMessageTokenType.TTV_CHAT_MSGTOKEN_URL_IMAGE:
                            {
                                ChatUrlImageMessageToken mt = (ChatUrlImageMessageToken)token;
                                sb.Append("[").Append(mt.Url).Append("]");
                                break;
                            }
                    }
                }

                DebugOverlay.Instance.AddViewportText(sb.ToString());
                sb.Remove(0, sb.Length);
            }
        }
    }
예제 #4
0
 protected void FireTokenizedMessagesReceived(string channelName, ChatTokenizedMessage[] messages)
 {
     try
     {
         if (m_ChatController.TokenizedMessagesReceived != null)
         {
             m_ChatController.TokenizedMessagesReceived(channelName, messages);
         }
     }
     catch (Exception x)
     {
         ReportError(x.ToString());
     }
 }
예제 #5
0
            void IChatChannelListener.ChatChannelTokenizedMessageCallback(string channelName, ChatTokenizedMessage[] messageList)
            {
                for (int i = 0; i < messageList.Length; ++i)
                {
                    m_TokenizedMessages.AddLast(messageList[i]);
                }

                FireTokenizedMessagesReceived(m_ChannelName, messageList);

                // cap the number of messages cached
                while (m_TokenizedMessages.Count > MessageHistorySize)
                {
                    m_TokenizedMessages.RemoveFirst();
                }
            }
예제 #6
0
        void IChatCallbacks.ChatChannelTokenizedMessageCallback(ChatTokenizedMessage[] messageList)
        {
            for (int i = 0; i < messageList.Length; ++i)
            {
                m_TokenizedMessages.AddLast(messageList[i]);
            }

            try
            {
                if (TokenizedMessagesReceived != null)
                {
                    this.TokenizedMessagesReceived(messageList);
                }
            }
            catch (Exception x)
            {
                ReportError(string.Format("Error in ChatChannelTokenizedMessageCallback: {0}", x.ToString()));
            }

            // cap the number of messages cached
            while (m_TokenizedMessages.Count > m_MessageHistorySize)
            {
                m_TokenizedMessages.RemoveFirst();
            }
        }