Esempio n. 1
0
 //接收客户端消息
 private void App_NewRequestReceived(MySession session, MyRequestInfo requestInfo)
 {
     this.Dispatcher.BeginInvoke(new Action(() =>
     {
         if (requestInfo == null)
         {
             return;
         }
         if (!requestInfo.IsHeart)
         {
             txbReceive.AppendText($"收到{session.SessionID}消息:{requestInfo.Body}" + '\n');
         }
         //是否显示心跳包
         else if (cbIgnoreHeart.IsChecked == false)
         {
             txbReceive.AppendText($"收到{session.SessionID}心跳:{requestInfo.Body}" + '\n');
         }
         //发送心跳反馈
         if (requestInfo.IsHeart && cbSendHeart.IsChecked == true)
         {
             var msg = CommandBuilder.BuildHeartCmd();
             if (session.Connected)
             {
                 session.Send(msg, 0, msg.Length);
             }
         }
     }));
 }
Esempio n. 2
0
 //接收客户端消息
 private void App_NewRequestReceived(MySession session, MyRequestInfo requestInfo)
 {
     if (requestInfo == null)
     {
         return;
     }
 }