예제 #1
0
        void AsyncRev(IAsyncResult ar)
        {
            int revSize = _socket.EndReceive(ar);

            if (revSize > 0)
            {
                MsgBase msg = ProtoLayer.DecodeMsg(_readBuff);

                GameEntity.Instance.gNetManager.AddRevMsg(msg);
            }
            if (bRev == false)
            {
                return;
            }

            //继续等待消息
            StartMsgRecieve();
        }
예제 #2
0
        public void StartMsgSend()
        {
            if (bSend)
            {
                return;         //正在发送
            }
            MsgBase msg = GameEntity.Instance.gNetManager.GetOneSendMsg();

            if (msg == null)
            {
                bSend = false;
            }
            else
            {
                bSend = true;
                byte[] sendData = ProtoLayer.EncodeMsg(msg);

                _socket.BeginSend(sendData, 0, sendData.Length, SocketFlags.None, AsyncSend, null);
            }
        }
예제 #3
0
        //连接层 接收消息 加入列表
        public void AddRevMsg(MsgBase msg)
        {
            //Todo线程安全

            _revList.Add(msg);
        }