Esempio n. 1
0
        public static async Task <QbservableProtocol> NegotiateServerAsync(NetworkStream stream, IRemotingFormatter formatter, QbservableServiceOptions serviceOptions, CancellationToken cancel)
        {
            // TODO: Enable protocol registration and implement actual protocol negotiation

            var protocol = new DefaultQbservableProtocol(stream, formatter, serviceOptions, cancel);

            var buffer = new byte[4];

            await protocol.ReceiveAsync(buffer, 0, 4).ConfigureAwait(false);

            await protocol.SendAsync(buffer, 0, 4).ConfigureAwait(false);

            return(protocol);
        }
Esempio n. 2
0
        public static async Task <QbservableProtocol> NegotiateClientAsync(NetworkStream stream, IRemotingFormatter formatter, CancellationToken cancel)
        {
            // TODO: Enable protocol registration and implement actual protocol negotiation

            var protocol = new DefaultQbservableProtocol(stream, formatter, cancel);

            const int ping = 123;

            var buffer = BitConverter.GetBytes(ping);

            await protocol.SendAsync(buffer, 0, 4).ConfigureAwait(false);

            await protocol.ReceiveAsync(buffer, 0, 4).ConfigureAwait(false);

            Contract.Assume(BitConverter.ToInt32(buffer, 0) == ping);

            return(protocol);
        }