Пример #1
0
 //回车键触发这个函数
 public void ToSendText(string text)
 {
     text.Trim();
     if (this.toggle.isOn)
     {
         if (text.Length > 0)
         {
             var strs = text.Split(' ');
             if (strs.Length != 2 || int.Parse(strs[1]) == null)
             {
                 //层层封装后,服务器和客户端之间发送消息,就可以这样简单
                 MessageMgr.Q_SendText(text);
                 //MessageMgr.SendObject(MessageData.Init(new MessageData(), text, UserName));
             }
             else
             {
                 MessageMgr.SendMessage(SocketNetWork.udpClientSocket, text, SocketNetWork.udpServerEnd);
                 //MessageMgr.SendObject(MessageData.Init(new MessageData(), Convert.ToInt32(strs[0]), Convert.ToInt32(strs[1]), UserName));
             }
         }
     }
     else
     {
         //MessageMgr.SendMessage(SocketNetWork.udpClientSocket, text, SocketNetWork.udpServerEnd);
         MessageMgr.SendObject(SocketNetWork.tcpServerSocket, MessageData.Init(text, MessageType.Merge, UserName));
     }
 }
Пример #2
0
 public void BeginReceive()
 {
     MessageMgr.Q_SendText("Hello");
     connectT = new Thread(SocketReceiver);
     connectT.Start();
 }