Ejemplo n.º 1
0
        private void CreateContext(Encoding encoding, int bufferSegmentSize, int bufferSegmentCount = 512)
        {
            _segmentProvider = new BufferSegmentProvider(bufferSegmentCount, bufferSegmentSize);

            _reader = new UnsafeBinaryReader(encoding);
            _reader.SetBuffers(_segmentProvider.GetBufferSegments());

            _writer = _segmentProvider.GetBinaryWriter(encoding);
        }
Ejemplo n.º 2
0
        public ReleasableMessage DeserializeWithLengthPrefix(List <BufferSegment> framedMessage, UnsafeBinaryReader binaryReader)
        {
            binaryReader.SetBuffers(framedMessage);
            var messageTypeId = new MessageTypeId(binaryReader.ReadUInt32());

            var serializationEngine = _messageEnginesByTypeId[messageTypeId];
            var message             = serializationEngine.Allocator.Allocate();

            serializationEngine.Serializer.Deserialize(message, binaryReader);

            return(new ReleasableMessage(messageTypeId, message, serializationEngine.Releaser));
        }