connection method

BroadcastDriver connection([
  1. String? name
])

Get the broadcast driver for the given name, or the default connection.

Calling without arguments returns (and caches) the default connection defined by broadcasting.default in config. Passing an explicit name resolves that named connection without affecting the cache.

final driver = BroadcastManager().connection();          // default
final reverb = BroadcastManager().connection('reverb'); // named

Implementation

BroadcastDriver connection([String? name]) {
  if (_cachedConnection != null && name == null) {
    return _cachedConnection!;
  }

  final connectionName =
      name ?? Config.get<String>('broadcasting.default', 'null')!;
  final resolved = _resolveConnection(connectionName);

  if (name == null) {
    _cachedConnection = resolved;
  }

  return resolved;
}