示例#1
0
        public HubServer(HubLifetimeManager <THub> lifetimeManager,
                         IHubInvoker <THub> hubInvoker,
                         ILoggerFactory loggerFactory)
        {
            _lifetimeManager = lifetimeManager;
            _hubInvoker      = hubInvoker;

            _loggerFactory = loggerFactory;
            _logger        = loggerFactory.CreateLogger <HubServer <THub> >();
        }
示例#2
0
 public HubEndPoint(HubLifetimeManager <THub> lifetimeManager,
                    IHubProtocolResolver protocolResolver,
                    IOptions <HubOptions> hubOptions,
                    ILoggerFactory loggerFactory,
                    IUserIdProvider userIdProvider,
                    IHubInvoker <THub> hubInvoker)
 {
     _protocolResolver = protocolResolver;
     _lifetimeManager  = lifetimeManager;
     _loggerFactory    = loggerFactory;
     _hubOptions       = hubOptions.Value;
     _logger           = loggerFactory.CreateLogger <HubEndPoint <THub> >();
     _userIdProvider   = userIdProvider;
     _hubInvoker       = hubInvoker;
 }
示例#3
0
        public ServiceConnection(IConnection connection,
                                 IHubProtocol protocol,
                                 HubLifetimeManager <THub> lifetimeManager,
                                 IHubInvoker <THub> hubInvoker,
                                 ILoggerFactory loggerFactory)
        {
            _connection      = connection ?? throw new ArgumentNullException(nameof(connection));
            _protocol        = protocol ?? throw new ArgumentNullException(nameof(protocol));
            _loggerFactory   = loggerFactory ?? NullLoggerFactory.Instance;
            _logger          = _loggerFactory.CreateLogger <ServiceConnection <THub> >();
            _hubInvoker      = hubInvoker;
            _lifetimeManager = lifetimeManager;
            _output          = Channel.CreateUnbounded <HubMessage>();

            // Create the timer for timeout, but disabled by default (we enable it when started).
            _timeoutTimer = new Timer(state => ((ServiceConnection <THub>)state).TimeoutElapsed(), this, Timeout.Infinite, Timeout.Infinite);

            connection.OnReceived((data, state) => ((ServiceConnection <THub>)state).OnDataReceivedAsync(data), this);
        }