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));
        }
示例#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);
        }