start method

Future<void> start()

Starts the router.

This method initializes and starts all configured transports, making the router ready to receive and send messages.

Throws an ExceptionTransport if no transports are configured.

Implementation

Future<void> start() async {
  if (_isRunning) return;
  if (transports.isEmpty) {
    throw const ExceptionTransport('Need at least one Transport!');
  }
  for (final transport in transports) {
    transport
      ..logger = logger
      ..onMessage = onMessage
      ..ttl = messageTTL.inSeconds;
    await transport.start();
  }
  _isRunning = true;
  _log('Start listen $transports with key $_selfId');
}