예제 #1
0
        /// <summary>
        /// 发送网络消息
        /// </summary>
        /// <param name="opCode">操作码</param>
        /// <param name="subCode">子操作</param>
        /// <param name="value">参数</param>
        public void Send(int opCode, int subCode, object value)
        {
            SocketMsg msg = new SocketMsg(opCode, subCode, value);

            byte[] data   = EncodeTool.EncodeMsg(msg);
            byte[] packet = EncodeTool.EncodePacket(data);

            Send(packet);
        }
예제 #2
0
        public void Send(int opCode, int subCode, object value)
        {
            SocketMsg msg = new SocketMsg(opCode, subCode, value);

            byte[] data   = EncodeTool.EncodeMsg(msg);     // 把需要发送的 SocketMsg 消息 转换成 字节数组
            byte[] packet = EncodeTool.EncodePacket(data); // 再把字节数组 封装成 包头 + 包尾

            sendQue.Enqueue(packet);
            if (!isSendProcess)
            {
                Send();
            }
        }
예제 #3
0
        /// <summary>
        /// 发送网络消息
        /// </summary>
        /// <param name="opCode">操作码</param>
        /// <param name="subCode">子操作</param>
        /// <param name="value">参数</param>
        public void Send(int opCode, int subCode, object value)
        {
            SocketMsg msg = new SocketMsg(opCode, subCode, value);

            byte[] data   = EncodeTool.EncodeMsg(msg);
            byte[] packet = EncodeTool.EncodePacket(data);

            //存入消息队列里面
            sendQueue.Enqueue(packet);
            if (!isSendProcess)
            {
                send();
            }
        }
예제 #4
0
        /// <summary>
        /// 发送数据
        /// </summary>
        /// <param name="opCode"></param>
        /// <param name="subCode"></param>
        /// <param name="value"></param>
        public void Send(int opCode, int subCode, object value)
        {
            SocketMsg msg = new SocketMsg(opCode, subCode, value);

            // 先变成 socketMsg ,再变成 包头 + 包尾 的形式
            byte[] data = EncodeTool.EncodeMsg(msg);
            //
            byte[] packet = EncodeTool.EncodePacket(data);
            //现存好数据,然后再发送
            sendQueue.Enqueue(packet);

            if (!isSendProcess)
            {
                // 处理一下发送消息
                send();
            }
        }