Example #1
0
 public void sendMsg(ChatRequest client)
 {
     if (tcpclient != null)
     {
         if (tcpclient.Connected)
         {
             SendData(client.ToBytes());
         }
     }
     else
     {
         //	showMessageTip ("聊天服务器断开,正在重连。。。");
         Connect();
     }
 }
Example #2
0
 public void sendMsg(ChatRequest client)
 {
     MyDebug.Log("--chatSocketUrl-------sendMsg-----sendMsg----");
     if (tcpclient != null)
     {
         if (tcpclient.Connected)
         {
             SendData(client.ToBytes());
         }
     }
     else
     {
         //	showMessageTip ("聊天服务器断开,正在重连。。。");
         Connect();
     }
 }
 public bool sendMsg(ChatRequest client)
 {
     if (_status != SocketStatus.CONNECTED || _tcpclient == null || !_tcpclient.Connected)
     {
         //Debug.Log ("未建立连接,不能发送请求");
         return(false);
     }
     try
     {
         byte[]        data   = client.ToBytes();
         NetworkStream stream = _tcpclient.GetStream();
         stream.Write(data, 0, data.Length);
     }
     catch (Exception e)
     {
         setStatus(SocketStatus.DISCONNECT, e.ToString(), _tcpclient);
         return(false);
     }
     return(true);
 }