Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HubConnectionContext"/> class.
        /// </summary>
        /// <param name="connectionContext">The underlying <see cref="ConnectionContext"/>.</param>
        /// <param name="loggerFactory">The logger factory.</param>
        /// <param name="contextOptions">The options to configure the HubConnectionContext.</param>
        public HubConnectionContext(ConnectionContext connectionContext, HubConnectionContextOptions contextOptions, ILoggerFactory loggerFactory)
        {
            _keepAliveInterval     = contextOptions.KeepAliveInterval.Ticks;
            _clientTimeoutInterval = contextOptions.ClientTimeoutInterval.Ticks;
            _streamBufferCapacity  = contextOptions.StreamBufferCapacity;
            _maxMessageSize        = contextOptions.MaximumReceiveMessageSize;

            _connectionContext  = connectionContext;
            _logger             = loggerFactory.CreateLogger <HubConnectionContext>();
            ConnectionAborted   = _connectionAbortedTokenSource.Token;
            _closedRegistration = connectionContext.ConnectionClosed.Register((state) => ((HubConnectionContext)state !).Abort(), this);

            HubCallerContext = new DefaultHubCallerContext(this);

            _systemClock       = contextOptions.SystemClock ?? new SystemClock();
            _lastSendTimeStamp = _systemClock.UtcNowTicks;

            // We'll be avoiding using the semaphore when the limit is set to 1, so no need to allocate it
            var maxInvokeLimit = contextOptions.MaximumParallelInvocations;

            if (maxInvokeLimit != 1)
            {
                ActiveInvocationLimit = new SemaphoreSlim(maxInvokeLimit, maxInvokeLimit);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HubConnectionContext"/> class.
        /// </summary>
        /// <param name="connectionContext">The underlying <see cref="ConnectionContext"/>.</param>
        /// <param name="loggerFactory">The logger factory.</param>
        /// <param name="contextOptions">The options to configure the HubConnectionContext.</param>
        public HubConnectionContext(ConnectionContext connectionContext, HubConnectionContextOptions contextOptions, ILoggerFactory loggerFactory)
        {
            _keepAliveInterval     = contextOptions.KeepAliveInterval.Ticks;
            _clientTimeoutInterval = contextOptions.ClientTimeoutInterval.Ticks;
            _streamBufferCapacity  = contextOptions.StreamBufferCapacity;

            _connectionContext = connectionContext;
            _logger            = loggerFactory.CreateLogger <HubConnectionContext>();
            ConnectionAborted  = _connectionAbortedTokenSource.Token;

            HubCallerContext = new DefaultHubCallerContext(this);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="HubConnectionContext"/> class.
        /// </summary>
        /// <param name="connectionContext">The underlying <see cref="ConnectionContext"/>.</param>
        /// <param name="loggerFactory">The logger factory.</param>
        /// <param name="contextOptions">The options to configure the HubConnectionContext.</param>
        public HubConnectionContext(ConnectionContext connectionContext, HubConnectionContextOptions contextOptions, ILoggerFactory loggerFactory)
        {
            _keepAliveInterval     = contextOptions.KeepAliveInterval.Ticks;
            _clientTimeoutInterval = contextOptions.ClientTimeoutInterval.Ticks;
            _streamBufferCapacity  = contextOptions.StreamBufferCapacity;
            _maxMessageSize        = contextOptions.MaximumReceiveMessageSize;

            _connectionContext = connectionContext;
            _logger            = loggerFactory.CreateLogger <HubConnectionContext>();
            ConnectionAborted  = _connectionAbortedTokenSource.Token;

            HubCallerContext = new DefaultHubCallerContext(this);

            _systemClock       = contextOptions.SystemClock ?? new SystemClock();
            _lastSendTimeStamp = _systemClock.UtcNowTicks;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HubConnectionContext"/> class.
        /// </summary>
        /// <param name="connectionContext">The underlying <see cref="ConnectionContext"/>.</param>
        /// <param name="loggerFactory">The logger factory.</param>
        /// <param name="contextOptions">The options to configure the HubConnectionContext.</param>
        public HubConnectionContext(ConnectionContext connectionContext, HubConnectionContextOptions contextOptions, ILoggerFactory loggerFactory)
        {
            _keepAliveInterval     = contextOptions.KeepAliveInterval.Ticks;
            _clientTimeoutInterval = contextOptions.ClientTimeoutInterval.Ticks;
            _streamBufferCapacity  = contextOptions.StreamBufferCapacity;
            _maxMessageSize        = contextOptions.MaximumReceiveMessageSize;

            _connectionContext = connectionContext;
            _logger            = loggerFactory.CreateLogger <HubConnectionContext>();
            ConnectionAborted  = _connectionAbortedTokenSource.Token;

            HubCallerContext = new DefaultHubCallerContext(this);

            if (AppContext.TryGetSwitch("Microsoft.AspNetCore.SignalR.UseAbsoluteClientTimeout", out var useAbsoluteClientTimeout))
            {
                _useAbsoluteClientTimeout = useAbsoluteClientTimeout;
            }
        }