public HubConnection(IConnection connection, IHubProtocol protocol, ILoggerFactory loggerFactory) { if (connection == null) { throw new ArgumentNullException(nameof(connection)); } if (protocol == null) { throw new ArgumentNullException(nameof(protocol)); } _connection = connection; _binder = new HubBinder(this); _protocol = protocol; _loggerFactory = loggerFactory ?? NullLoggerFactory.Instance; _logger = _loggerFactory.CreateLogger <HubConnection>(); _connection.OnReceived((data, state) => ((HubConnection)state).OnDataReceivedAsync(data), this); Closed = _connection.Closed.ContinueWith(task => { Shutdown(task.Exception); return(task); }).Unwrap(); // Create the timer for timeout, but disabled by default (we enable it when started). _timeoutTimer = new Timer(state => ((HubConnection)state).TimeoutElapsed(), this, Timeout.Infinite, Timeout.Infinite); }
public HubConnection(IConnection connection, IHubProtocol protocol, ILoggerFactory loggerFactory) { if (connection == null) { throw new ArgumentNullException(nameof(connection)); } if (protocol == null) { throw new ArgumentNullException(nameof(protocol)); } _connection = connection; _binder = new HubBinder(this); _protocol = protocol; _loggerFactory = loggerFactory ?? NullLoggerFactory.Instance; _logger = _loggerFactory.CreateLogger <HubConnection>(); _connection.Received += OnDataReceivedAsync; _connection.Closed += Shutdown; }
public HubConnection(IConnection connection, IHubProtocol protocol, ILoggerFactory loggerFactory) { if (connection == null) { throw new ArgumentNullException(nameof(connection)); } if (protocol == null) { throw new ArgumentNullException(nameof(protocol)); } _connection = connection; _binder = new HubBinder(this); _protocol = protocol; _loggerFactory = loggerFactory ?? NullLoggerFactory.Instance; _logger = _loggerFactory.CreateLogger <HubConnection>(); _connection.OnReceived((data, state) => ((HubConnection)state).OnDataReceivedAsync(data), this); Closed = _connection.Closed.ContinueWith(task => { Shutdown(task.Exception); return(task); }).Unwrap(); }