コード例 #1
0
        public MultiplexingConnection(Stream stream, EndPoint localEndPoint, EndPoint remoteEndPoint,
                                      ILogger <MultiplexingConnection> logger)
        {
            _stream       = stream ?? throw new ArgumentNullException(nameof(stream));
            LocalEndPoint = localEndPoint ?? throw new ArgumentNullException(nameof(localEndPoint));
            EndPoint      = remoteEndPoint ?? throw new ArgumentNullException(nameof(remoteEndPoint));
            _logger       = logger ?? throw new ArgumentNullException(nameof(logger));

            //allocate a buffer
            _receiveBuffer       = new byte[1024 * 16];
            _receiveBufferLength = 0;

            ConnectionId = ConnectionIdProvider.GetNextId();

            Task.Run(ReceiveResponsesAsync);
        }
コード例 #2
0
        public MultiplexingConnection(Stream stream, EndPoint localEndPoint, EndPoint remoteEndPoint,
                                      ILogger <MultiplexingConnection> logger)
        {
            _stream       = stream ?? throw new ArgumentNullException(nameof(stream));
            LocalEndPoint = localEndPoint ?? throw new ArgumentNullException(nameof(localEndPoint));
            EndPoint      = remoteEndPoint ?? throw new ArgumentNullException(nameof(remoteEndPoint));
            _logger       = logger ?? throw new ArgumentNullException(nameof(logger));

            ConnectionId = ConnectionIdProvider.GetNextId();

            _endPointString      = EndPoint.ToString() ?? DiagnosticsReportProvider.UnknownEndpointValue;
            _localEndPointString = LocalEndPoint.ToString() ?? DiagnosticsReportProvider.UnknownEndpointValue;
            _connectionIdString  = ConnectionId.ToString(CultureInfo.InvariantCulture);

            _stopwatch = new Stopwatch();
            _stopwatch.Start();

            // We don't need the execution context to flow to the receive loop
            using (ExecutionContext.SuppressFlow())
            {
                Task.Run(ReceiveResponsesAsync);
            }
        }