public override async Task WriteData(ITransport transport, string messageId, ITransportMetadata metadata, Action <IProtocolWriter> handler)
        {
            using (var buffer = new MemoryStream())
            {
                var writer = new MessagePackProtocolWriter(buffer);
                handler(writer);

                buffer.Position = 0;
                var data = buffer.ToArray();
                await transport.Send(messageId, new TransportMessage(data, VolatileTransportMetadata.FromMetadata(metadata)));
            }
        }
        public override async Task <Func <Func <IProtocolReader, ITransportMetadata, TResult>, Task <TResult> > > WriteAndReadData <TResult>(ITransport transport, ITransportMetadata metadata, Action <IProtocolWriter> handler)
        {
            Func <Task <TransportMessage> > receiveHandler;

            using (var buffer = new MemoryStream())
            {
                var writer = new MessagePackProtocolWriter(buffer);
                handler(writer);

                buffer.Position = 0;
                var data = buffer.ToArray();
                receiveHandler = await transport.SendAndReceive(new TransportMessage(data, VolatileTransportMetadata.FromMetadata(metadata)));
            }

            return(new Func <Func <IProtocolReader, ITransportMetadata, TResult>, Task <TResult> >(async(readHandler) => {
                var receivedData = await receiveHandler();

                var buffer = new MemoryStream(receivedData.Payload);
                var reader = new MessagePackProtocolReader(buffer);

                return readHandler(reader, receivedData.Metadata);
            }));
        }