start method

Future<void> start()

Binds the TLS endpoint and starts the liveness watchdog.

Implementation

Future<void> start() async {
  if (_endpoint != null) return;
  await _resolveUid();
  _startTunnelTls();
  broker.start();
  final dir = config.tlsDirectory;
  if (dir != null && dir.isNotEmpty) {
    final source = PemTlsSource(
      dir,
      label: 'hub TLS',
      checkInterval: config.tlsReloadInterval,
      logger: config.logger,
      onReloaded: _rebindMain,
    );
    source.load();
    _mainTls = source;
    _endpoint = await WsServerEndpoint.bind(
      host: config.host,
      port: config.port,
      securityContext: source.context!,
      onConnection: broker.accept,
      shared: true,
    );
    source.start();
  } else {
    _endpoint = await WsServerEndpoint.bind(
      host: config.host,
      port: config.port,
      securityContext: config.securityContext!,
      onConnection: broker.accept,
    );
  }
}