コード例 #1
0
        public Answer PushBroadcastMessage(Int64 connectionId, string endpoint, Quest quest)
        {
            AdvanceAnswer.SendAnswer(new Answer(quest));

            if (questProcessor == null)
            {
                return(null);
            }

            long from = quest.Want <long>("from");
            long mid  = quest.Want <long>("mid");

            if (duplicatedFilter.CheckBroadcastMessage(from, mid) == false)
            {
                return(null);
            }

            RTMMessage rtmMessage = BuildRTMMessage(quest, from, 0, mid);

            if (rtmMessage.messageType == (byte)MessageType.Chat)
            {
                if (rtmMessage.translatedInfo != null)
                {
                    questProcessor.PushBroadcastChat(rtmMessage);
                }
            }
            else if (rtmMessage.messageType == (byte)MessageType.Cmd)
            {
                questProcessor.PushBroadcastCmd(rtmMessage);
            }
            else if (rtmMessage.messageType >= 40 && rtmMessage.messageType <= 50)
            {
                questProcessor.PushBroadcastFile(rtmMessage);
            }
            else
            {
                questProcessor.PushBroadcastMessage(rtmMessage);
            }

            return(null);
        }
コード例 #2
0
        public Answer PushBroadcastMessage(Int64 connectionId, string endpoint, Quest quest)
        {
            AdvanceAnswer.SendAnswer(new Answer(quest));

            if (questProcessor == null)
            {
                return(null);
            }

            long from = quest.Want <long>("from");
            long mid  = quest.Want <long>("mid");

            if (duplicatedFilter.CheckBroadcastMessage(from, mid) == false)
            {
                return(null);
            }

            byte   mtype = quest.Want <byte>("mtype");
            string attrs = quest.Want <string>("attrs");
            long   mtime = quest.Want <long>("mtime");

            if (mtype == RTMClient.MessageMType_Chat)
            {
                TranslatedMessage tm = ProcessChatMessage(quest, out string orginialMessage);
                if (tm == null)
                {
                    questProcessor.PushBroadcastChat(from, mid, orginialMessage, attrs, mtime);
                }
                else
                {
                    questProcessor.PushBroadcastChat(from, mid, tm, attrs, mtime);
                }

                return(null);
            }

            MessageInfo messageInfo = BuildMessageInfo(quest);

            if (mtype == RTMClient.MessageMType_Audio)
            {
                byte[] audioData = messageInfo.binaryData;

                if (!messageInfo.isBinary)
                {
                    audioData = RTMClient.ConvertStringToByteArray(messageInfo.message);
                }

                questProcessor.PushBroadcastAudio(from, mid, audioData, attrs, mtime);
                return(null);
            }

            if (mtype == RTMClient.MessageMType_Cmd)
            {
                questProcessor.PushBroadcastCmd(from, mid, messageInfo.message, attrs, mtime);
            }
            else if (mtype >= 40 && mtype <= 50)
            {
                questProcessor.PushBroadcastFile(from, mtype, mid, messageInfo.message, attrs, mtime);
            }
            else
            {
                if (messageInfo.isBinary)
                {
                    questProcessor.PushBroadcastMessage(from, mtype, mid, messageInfo.binaryData, attrs, mtime);
                }
                else
                {
                    questProcessor.PushBroadcastMessage(from, mtype, mid, messageInfo.message, attrs, mtime);
                }
            }

            return(null);
        }