Exemplo n.º 1
0
        public static ChatMessage CreateChatMessage(ReceieveMessage message)
        {
            PlayMsgVoice();
            ChatMessage chatMessage = null;

            switch (message.Action)
            {
            case (int)CommandType.PrivateChat:
                var privateRequest = JsonHelper.DeserializeObj <PrivateChatRequest>(message.DataStr);
                chatMessage = privateRequest.ToChatMessage();
                break;

            case (int)CommandType.TeamChat:
                var teamRequest = JsonHelper.DeserializeObj <TeamChatRequest>(message.DataStr);
                chatMessage = teamRequest.ToChatMessage();
                break;

            case (int)CommandType.GroupChat:
                var groupRequest = JsonHelper.DeserializeObj <GroupChatRequest>(message.DataStr);
                chatMessage = groupRequest.ToChatMessage();
                break;

            default:
                break;
            }
            AddNewChat(chatMessage);
            return(chatMessage);
        }
Exemplo n.º 2
0
        private static void SavectConclusionResult(ReceieveMessage res)
        {
            SaveToFile(res.DataStr);
            var info = XmlHelper.Deserialize <ctConclusionResult>(res.DataStr);

            sqlAction.SavectConclusionResultData(info);
        }
Exemplo n.º 3
0
 private void Client_OnReveieveData(ReceieveMessage message)
 {
     this.richTextBox1.InvokeOnUiThreadIfRequired(() =>
     {
         richTextBox1.AppendText(message.DataStr + "\r\n\r\n");
     });
 }
Exemplo n.º 4
0
        public static ReceieveMessage CreateReceieveMessage(byte[] data, ref int newOffset)
        {
            ReceieveMessage message    = new ReceieveMessage();
            int             tempOffset = newOffset;
            var             lenBytes   = new byte[4];

            Array.Copy(data, tempOffset, lenBytes, 0, 4);
            message.Length = BitConverter.ToInt32(lenBytes, 0);

            tempOffset += 4;
            var timeBytes = new byte[14];

            Array.Copy(data, tempOffset, timeBytes, 0, 14);
            message.TimeStamp = Encoding.UTF8.GetString(timeBytes);

            tempOffset += 14;
            var actionBytes = new byte[4];

            Array.Copy(data, tempOffset, actionBytes, 0, 4);
            message.Action = BitConverter.ToInt32(actionBytes, 0);

            tempOffset += 4;
            var dataLength = message.Length - 18;
            var dataBytes  = new byte[dataLength];

            Array.Copy(data, tempOffset, dataBytes, 0, dataLength);
            message.DataStr = Encoding.UTF8.GetString(dataBytes);
            newOffset      += message.Length + 4;
            return(message);
            //    LoginResult info = JsonHelper.DeserializeObj<LoginResult>(datas);
        }
Exemplo n.º 5
0
        private void Client_OnReveieveData(ReceieveMessage message)
        {
            //   messageList.InvokeOnUiThreadIfRequired(() => messageList.AppendText(message.DataStr));
            switch (message.Action)
            {
            case (int)CommandType.OnlineList:    //在线用户
                var userList2 = JsonHelper.DeserializeObj <List <OnlineListResult> >(message.DataStr);
                onlineInfo.OnOnlineChange(userList2);
                break;

            case (int)CommandType.PrivateChat:    //接收到学生私聊信息
                var PrivateChatMessage = JsonHelper.DeserializeObj <PrivateChatRequest>(message.DataStr);
                this.InvokeOnUiThreadIfRequired(() => { ReceievePrivateMessage(PrivateChatMessage); });
                break;

            case (int)CommandType.TeamChat:    //收到群聊信息
                var TeamChatRequest = JsonHelper.DeserializeObj <TeamChatRequest>(message.DataStr);
                this.InvokeOnUiThreadIfRequired(() => { ReceieveTeamMessage(TeamChatRequest); });
                break;

            case (int)CommandType.GroupChat:    //收到群聊信息
                var groupChatRequest = JsonHelper.DeserializeObj <GroupChatRequest>(message.DataStr);
                this.InvokeOnUiThreadIfRequired(() => { ReceieveGroupMessage(groupChatRequest); });
                break;

            case (int)CommandType.OneUserLogIn:    //某个学生登录
                var newUser = JsonHelper.DeserializeObj <List <OnlineListResult> >(message.DataStr);
                onlineInfo.OnNewUserLoginIn(newUser);
                //  OnlineInfo_AddOnLine(onlineInfo, e2);
                break;

            case (int)CommandType.StudentCall:    //课堂点名
                var callInfo = JsonHelper.DeserializeObj <StuCallRequest>(message.DataStr);
                UpdateOnLineStatus(callInfo);
                break;

            case (int)CommandType.UserLoginOut:    //用户登出
                var loginoutInfo = JsonHelper.DeserializeObj <UserLogoutResponse>(message.DataStr);
                onlineInfo.OnUserLoginOut(loginoutInfo);
                break;

            case (int)CommandType.ScreenInteract:    //收到视频流
                ScreenInteract_Response resp = JsonHelper.DeserializeObj <ScreenInteract_Response>(message.DataStr);
                this.InvokeOnUiThreadIfRequired(() =>
                {
                    PlayRtspVideo(resp.url);
                });
                break;

            case (int)CommandType.StopScreenInteract:    //收到停止接收视频流
                this.InvokeOnUiThreadIfRequired(() =>
                {
                    StopPlay();
                });
                break;

            default:
                break;
            }
        }
Exemplo n.º 6
0
        private void DoReceiveChatMessage(ReceieveMessage message)
        {
            var chatMessage = GlobalVariable.CreateChatMessage(message);

            DoAction(() =>
            {
                OpenChatForm(chatMessage);
            });
        }
Exemplo n.º 7
0
        /// <summary>
        /// 处理收到的聊天信息
        /// </summary>
        /// <param name="message"></param>
        private void DoReceiveChatMessage(ReceieveMessage message)
        {
            var chatMessage = GlobalVariable.CreateChatMessage(message);

            this.InvokeOnUiThreadIfRequired(() =>
            {
                OpenOrCreateChatForm(chatMessage, true);
            });
        }
Exemplo n.º 8
0
        public async Task OnServerDataReceived(AsyncTcpSocketClient client, byte[] data, int offset, int count)
        {
            int             newOffset = offset;
            ReceieveMessage message   = null;

            while (newOffset < (offset + count))
            {
                message = TcpHelper.CreateReceieveMessage(data, ref newOffset);
                OnReceieveMessage(message);
            }
            await Task.CompletedTask;
        }
Exemplo n.º 9
0
 private void Client_OnReveieveData(ReceieveMessage message)
 {
     // TranMessage = resStr =>
     //  {
     if (message.Action == 2)
     {
         var result = JsonHelper.DeserializeObj <LoginResult>(message.DataStr);
         if (result.success)
         {
             DoAction(() =>
             {
                 this.DialogResult = DialogResult.OK;
                 GlobalVariable.client.OnReveieveData -= Client_OnReveieveData;
                 GlobalVariable.LoginUserInfo          = new LoginUserInfo
                 {
                     DisplayName = nickName,
                     UserName    = textBox1.Text.Trim(),
                     UserType    = ClientRole.Student,
                     No          = textBox2.Text.Trim()
                 };
                 this.Close();
             });
         }
         else
         {
             MessageBox.Show(result.msg);
         }
     }
     //  };
     //Action<string> action = (data) =>
     //{
     //    Thread.Sleep(3000);
     //    txtBox.AppendText(data);
     //};
     // Invoke(TranMessage, message.DataStr);
 }
Exemplo n.º 10
0
        private void Client_OnReveieveData(ReceieveMessage message)
        {
            messageList.InvokeOnUiThreadIfRequired(() => messageList.AppendText(message.DataStr));
            switch (message.Action)
            {
            case (int)CommandType.OnlineList:    //在线用户
                var userList2 = JsonHelper.DeserializeObj <List <OnlineListResult> >(message.DataStr);
                onlineInfo.OnOnlineChange(userList2);
                break;

            case (int)CommandType.PrivateChat:    //接收到学生私聊信息
                var PrivateChatResponse = JsonHelper.DeserializeObj <PrivateChatRequest>(message.DataStr);
                this.InvokeOnUiThreadIfRequired(() => { AppendToPrivateForm(PrivateChatResponse); });
                break;

            case (int)CommandType.OneUserLogIn:    //某个学生登录
                var newUser = JsonHelper.DeserializeObj <List <OnlineListResult> >(message.DataStr);

                onlineInfo.OnNewUserLoginIn(newUser);
                //  OnlineInfo_AddOnLine(onlineInfo, e2);
                break;

            case (int)CommandType.StudentCall:    //课堂点名
                var callInfo = JsonHelper.DeserializeObj <StuCallRequest>(message.DataStr);
                UpdateOnLineStatus(callInfo);
                break;

            case (int)CommandType.UserLoginOut:
                var loginoutInfo = JsonHelper.DeserializeObj <UserLogoutResponse>(message.DataStr);
                onlineInfo.OnUserLoginOut(loginoutInfo);
                break;

            default:
                break;
            }
        }
Exemplo n.º 11
0
 private void Client_OnReveieveData(ReceieveMessage message)
 {
     Invoke(new Action(() =>
     {
         var result = JsonHelper.DeserializeObj <LoginResult>(message.DataStr);
         if (result.success)
         {
             this.DialogResult = DialogResult.OK;
             GlobalVariable.client.OnReveieveData -= Client_OnReveieveData;
             GlobalVariable.LoginUserInfo          = new LoginUserInfo
             {
                 DisplayName = "老师",
                 UserName    = textBox1.Text.Trim(),
                 UserType    = ClientRole.Teacher,
                 No          = textBox2.Text.Trim()
             };
             this.Close();
         }
         else
         {
             MessageBox.Show(result.msg);
         }
     }));
 }
Exemplo n.º 12
0
        private static void SavectDeviceStatus(ReceieveMessage res)
        {
            var info = XmlHelper.Deserialize <ctDeviceStatus>(res.DataStr);

            sqlAction.SavectDeviceStatusData(info);
        }
Exemplo n.º 13
0
 private void MessageDue_OnReceieveMessage(ReceieveMessage message)
 {
     Loger.LogMessage("收到命令:" + JsonHelper.SerializeObj(message));
     OnReveieveData(message);
 }