Beispiel #1
0
        void PeekMessage()
        {
            if (_tryDisconnect > 0)
            {
                if (WAIT_DISCONNECT_TRIGGER == _tryDisconnect)
                {
                    OnDisconnect(8, "try disconnect timeout");
                }
                _tryDisconnect--;
                return;
            }

            lock (_resvMsgQueue)
            {
                int handleCount = 0;
                while (_resvMsgQueue.Count > 0)
                {
                    RecvMsg msg = _resvMsgQueue.Dequeue();
                    handleCount++;
                    if (!_protocol.HandleBody(msg._headerPack, msg._bodyPack, handleCount))
                    {
                        break;
                    }
                }
            }
        }
Beispiel #2
0
        public void StartRecvHeader()
        {
            _curRecvMsg = new RecvMsg();
            int headerSize = _protocol.GetHeadSize();

            _curRecvMsg._headerPack = new MessagePacket(headerSize);

            this.socket.BeginReceive(_curRecvMsg._headerPack._buffer, 0, headerSize, 0, new AsyncCallback(Callback_ReceiveHeadOK), _curRecvMsg._headerPack);
        }