HubConnection constructor

HubConnection(
  1. IConnection connection,
  2. Logger? logger,
  3. IHubProtocol protocol, {
  4. IRetryPolicy? reconnectPolicy,
})

Implementation

HubConnection(IConnection connection, Logger? logger, IHubProtocol protocol,
    {IRetryPolicy? reconnectPolicy})
    : _connection = connection,
      _logger = logger,
      _protocol = protocol,
      _reconnectPolicy = reconnectPolicy ?? DefaultRetryPolicy(),
      _handshakeProtocol = HandshakeProtocol() {
  serverTimeoutInMilliseconds = DEFAULT_TIMEOUT_IN_MS;
  keepAliveIntervalInMilliseconds = DEFAULT_PING_INTERVAL_IN_MS;

  _connection.onreceive = _processIncomingData;
  _connection.onclose = _connectionClosed;

  _callbacks = {};
  _methods = {};
  _closedCallbacks = [];
  _reconnectingCallbacks = [];
  _reconnectedCallbacks = [];
  _invocationId = 0;
  _receivedHandshakeResponse = false;
  _hubConnectionStateMaintainer =
      _HubConnectionStateMaintainer(HubConnectionState.Disconnected);
  _connectionStarted = false;

  _cachedPingMessage = _protocol.writeMessage(PingMessage());
}