Example #1
0
        public static void Send(ChatSession session, MsgInfo msg)
        {
            var frames = msg.ToFrame();

            foreach (var frame in frames)
            {
                Send(session, frame);
            }
        }
Example #2
0
        /// <summary>
        /// 向服务器发送命令行协议数据(此函数会将数据以Base64[UTF-8]方式编码,在服务器读取后,需要解码使用)
        /// </summary>
        /// <param name="cmd">请求的命令 </param>
        /// <param name="msg">数据</param>
        private void SendCmd(CMD cmd, MsgInfo msg)
        {
            msg.FromUser = tName.Text;
            var frames = msg.ToFrame(cmd.ToString().Length + 1);

            foreach (var frame in frames)
            {
                var byteData = string.Format(CMD_FORMAT, cmd, frame).ToBin();
                client.Send(byteData, 0, byteData.Length);
            }
        }