예제 #1
0
 /// <summary>
 /// websocket发送数据
 /// </summary>
 /// <param name="datas"></param>
 public void SendFrame(byte[] datas)
 {
     if (datas == null || datas.Length <= 0)
     {
         return;
     }
     byte[] _SendDatas = WebSocketFrame.GetDatas(1, Opcode.TextFrame, new ArraySegment <byte>(datas, 0, datas.Length));
     this.m_Stream.Write(_SendDatas, 0, _SendDatas.Length);
 }
예제 #2
0
        /// <summary>
        /// websocket发送数据
        /// </summary>
        /// <param name="content"></param>
        public void SendFrame(string content)
        {
            if (string.IsNullOrEmpty(content))
            {
                return;
            }

            byte[] _StringDatas = System.Text.Encoding.UTF8.GetBytes(content);
            byte[] _SendDatas   = WebSocketFrame.GetDatas(1, Opcode.TextFrame, new ArraySegment <byte>(_StringDatas, 0, _StringDatas.Length));
            this.m_Stream.Write(_SendDatas, 0, _SendDatas.Length);
        }