Exemplo n.º 1
0
 /// <summary>
 /// 发送数据
 /// </summary>
 /// <param name="dataBuf">发送数据</param>
 public void SendData(byte[] dataBuf)
 {
     if (_client.Connected && dataBuf.Length != 0)
     {
         var buffer = new byte[dataBuf.Length * sizeof(byte)];
         Buffer.BlockCopy(dataBuf, 0, buffer, 0, buffer.Length);
         _client.Send(buffer);
         GC.Collect();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 发送字符串数据(如果选择DataStream模式,请选择ReadDataStream方法)
 /// </summary>
 /// <param name="dataBuf"></param>
 public void SendString(string dataBuf)
 {
     if (_client.Connected && dataBuf.Length != 0)
     {
         if (_dataType == ChannelDataType.String)
         {
             _client.Send(dataBuf);
         }
         else
         {
             throw new Exception("Please Use SendDataStream() method for channel type of DataStream");
         }
     }
 }