build method

HubConnection build()

Creates a HubConnection from the configuration options specified in this builder.

Implementation

HubConnection build() {
  // Now create the connection
  if (_url == null) {
    throw Exception(
        'The \'HubConnectionBuilder.withUrl\' method must be called before building the connection.');
  }

  _httpConnectionOptions ??=
      HttpConnectionOptions(transport: _httpTransportType);

  final connection =
      HttpConnection(url: _url, options: _httpConnectionOptions!);

  return HubConnection(
    connection: connection,
    logging: (_httpConnectionOptions!.logging != null)
        ? _httpConnectionOptions!.logging
        : (l, m) => {},
    protocol: (_protocol == null) ? JsonHubProtocol() : _protocol!,
    reconnectPolicy: reconnectPolicy,
  );
}