コード例 #1
0
ファイル: EVEClientSocket.cs プロジェクト: lanicon/EVESharp
        private void ReceiveCallback(IAsyncResult asyncResult)
        {
            ReceiveCallbackState state = asyncResult.AsyncState as ReceiveCallbackState;

            try
            {
                state.Received = this.EndReceive(asyncResult);
            }
            catch (Exception e)
            {
                // an exception here means the connection closed
                this.HandleException(e);
                return;
            }

            // receiving 0 bytes means the socket has to be closed
            if (state.Received == 0)
            {
                this.ForcefullyDisconnect();
                this.FireOnConnectionLostHandler();
                return;
            }

            // queue the packets and process them
            this.mPacketizer.QueuePackets(state.Buffer, state.Received);
            this.mPacketizer.ProcessPackets();

            // if there is any pending to be processed pop it and call the receive callback
            this.FlushReceivingQueue();

            // begin receiving again
            this.BeginReceive(state.Buffer, this.mReceiveCallback);
        }
コード例 #2
0
        private void ReceiveCallback(IAsyncResult asyncResult)
        {
            ReceiveCallbackState state = asyncResult.AsyncState as ReceiveCallbackState;

            try
            {
                state.Received = this.EndReceive(asyncResult);
            }
            catch (Exception)
            {
                // an exception here means the connection closed
                return;
            }

            // queue the packets and process them
            this.mPacketizer.QueuePackets(state.Buffer, state.Received);
            this.mPacketizer.ProcessPackets();

            // if there is any pending to be processed pop it and call the receive callback
            this.FlushReceivingQueue();

            // begin receiving again
            this.BeginReceive(state.Buffer, this.mReceiveCallback);
        }