public static async Task <IConnection> UpgradeConnectionAsync(IConnection connection, StreamUpgradeAcceptor upgradeAcceptor, IDefaultCommunicationTimeouts defaultTimeouts)
        {
            ConnectionStream connectionStream = new ConnectionStream(connection, defaultTimeouts);
            Stream           stream           = await upgradeAcceptor.AcceptUpgradeAsync(connectionStream);

            return(new StreamConnection(stream, connectionStream));
        }
Exemple #2
0
        public StreamConnection(Stream stream, ConnectionStream innerStream)
        {
            Fx.Assert(stream != null, "StreamConnection: Stream cannot be null.");
            Fx.Assert(innerStream != null, "StreamConnection: Inner stream cannot be null.");

            this.stream      = stream;
            this.innerStream = innerStream;

            onRead  = Fx.ThunkCallback <Task <int>, object>(OnRead);
            onWrite = Fx.ThunkCallback <Task, object>(OnWrite);
        }