Пример #1
0
 public AsyncSendBufferManager(int bufferSize)
 {
     _dynamicBufferManager    = new DynamicBufferManager(bufferSize);
     _sendBufferList          = new List <SendBufferPacket>();
     _sendBufferPacket.Offset = 0;
     _sendBufferPacket.Count  = 0;
 }
Пример #2
0
        public AsyncUserToken(int asyncReceiveBufferSize)
        {
            _connectSocket              = null;
            _receiveEventArgs           = new SocketAsyncEventArgs();
            _receiveEventArgs.UserToken = this;
            _asyncReceiveBuffer         = new byte[asyncReceiveBufferSize];
            _receiveEventArgs.SetBuffer(_asyncReceiveBuffer, 0, _asyncReceiveBuffer.Length);
            _receiveBuffer = new DynamicBufferManager(10);

            _sendEventArgs           = new SocketAsyncEventArgs();
            _sendEventArgs.UserToken = this;
            _sendBuffer = new AsyncSendBufferManager(10);
        }
Пример #3
0
        private bool ProcessReceive(byte[] buffer, int offset, int count)
        {
            DynamicBufferManager receiveBuffer = _userToken.ReceiveBuffer;

            receiveBuffer.WriteBuffer(buffer, offset, count);

            if (receiveBuffer.DataCount >= sizeof(UInt16) + sizeof(UInt32))
            {
                bool result = ProcessPacket(receiveBuffer.Buffer, offset, count);
                if (result)
                {
                    receiveBuffer.Clear(count);
                }
                return(result);
            }
            return(true);
        }