Beispiel #1
0
        /// <inheritdoc />
        public async Task ProcessMessageAsync(PeerConnection connection, Stream stream, CancellationToken cancel = default(CancellationToken))
        {
            log.Debug("start processing requests from " + connection.RemoteAddress);
            var muxer = new Muxer
            {
                Channel    = stream,
                Connection = connection,
                Receiver   = true
            };

            muxer.SubstreamCreated += (s, e) => connection.ReadMessages(e, CancellationToken.None);

            // Attach muxer to the connection.  It now becomes the message reader.
            connection.MuxerEstablished.SetResult(muxer);
            await muxer.ProcessRequestsAsync();

            log.Debug("stop processing from " + connection.RemoteAddress);
        }