start method

Future<bool> start()

Starts the server and begins listening for incoming connections.

Returns a Future that completes with true if the server successfully starts, or false if it is already running.

Throws a StateError if the Gatekeeper cannot resolve.

Implementation

Future<bool> start() async {
  if (isStarted) return false;

  _zoneGuarded = Zone.current.fork(
      specification:
          ZoneSpecification(handleUncaughtError: _onUncaughtError));

  var started = await _zoneGuarded.run(_startImpl);
  if (!started) {
    throw StateError("Can't start `GatekeeperServer`");
  }

  var ok = await gatekeeper.resolve();
  if (!ok) {
    throw StateError("Can't resolve `Gatekeeper`");
  }

  return true;
}