private void HandleHeader(IPipelineHandlerContext context, IPipelineMessage message, ReceivedHeader headerMsg) { _packetType = _mapper.GetPacketType(_header.ContentId); if (_packetType == null) { // not supported, let the rest of the pipeline // handle the packet. context.SendUpstream(message); } else { _header = headerMsg.Header; var buffer = _bufferPool.PopSlice(); if (_header.ContentLength > buffer.Capacity) { throw new InvalidOperationException( string.Format( "Buffer ({0} bytes) is less than the packet content ({1} bytes). Sorry, that's not possible in the current version.", buffer.Capacity, _header.ContentLength)); } _bytesLeft = _header.ContentLength; _stream = new BufferPoolStream(_bufferPool, buffer); } }