Ejemplo n.º 1
0
        private async Task <(uint messageType, uint requestHandle, byte[] content)> SendAndReceiveAsync(IConversation sender, IConversation receiver, uint messageType, uint handle, byte[] content)
        {
            using var input    = new MemoryStream();
            using var transfer = new MemoryStream();
            using var output   = new MemoryStream();

            // write message into the body stream
            input.Write(content);
            input.Position = 0;

            // encrypt the message into the transfer stream
            await sender.EncryptMessageAsync(input, messageType, handle, transfer.WriteAsync, default);

            transfer.Position = 0;

            // dencrypt the message from the transfer stream
            var ret = await receiver.DecryptMessageAsync(output, transfer.ReadAsync, default);

            return(ret.messageType, ret.requestHandle, output.ToArray());
        }