ReverbBroadcastDriver class

A BroadcastDriver that connects to Laravel Reverb (Pusher-compatible) via a pure-Dart WebSocket client.

Handles the full Pusher protocol: connection handshake, application-level ping/pong, channel subscriptions (public, private, presence), event deduplication, interceptor chains, and automatic reconnection with exponential backoff.

Usage

final driver = ReverbBroadcastDriver({
  'host': 'localhost',
  'port': 8080,
  'scheme': 'ws',
  'app_key': 'my-app-key',
  'auth_endpoint': '/broadcasting/auth',
});
await driver.connect();
driver.channel('orders').listen('OrderShipped', (event) {
  print(event.data);
});
Implemented types

Constructors

ReverbBroadcastDriver(Map<String, dynamic> _config, {WebSocketChannel channelFactory(Uri uri)?, Future<Map<String, dynamic>> authFactory(String endpoint, Map<String, dynamic> data)?, Duration pongTimeout = _kPongTimeout, Random? random})
Creates a ReverbBroadcastDriver.

Properties

activityTimeout ↔ int
The activity timeout in seconds.
getter/setter pair
connectionState → Stream<BroadcastConnectionState>
A broadcast stream of BroadcastConnectionState transitions.
no setteroverride
hashCode → int
The hash code for this object.
no setterinherited
isConnected → bool
Whether the driver currently has an active connection.
no setteroverride
onReconnect → Stream<void>
A stream that emits once each time the driver successfully reconnects.
no setteroverride
pongTimeout → Duration
The duration to wait for a pong response after sending a ping.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
socketId → String?
The socket identifier assigned by the server, or null when not connected.
no setteroverride

Methods

addInterceptor(BroadcastInterceptor interceptor) → void
Registers an interceptor to be applied to all outbound and inbound messages processed by this driver.
override
backoffDelay(int attempt) → Duration
Computes the reconnect delay for attempt using exponential backoff with random jitter.
channel(String name) → BroadcastChannel
Returns a public BroadcastChannel for name.
override
classifyErrorCode(int code) → PusherErrorAction
Classifies a Pusher error code into a reconnection action.
connect() → Future<void>
Connects to the Reverb server. Idempotent: the driver never holds more than one socket, however many callers ask.
override
disconnect() → Future<void>
Closes the connection and releases all resources.
override
join(String name) → BroadcastPresenceChannel
Joins a presence channel for name and returns it.
override
leave(String name) → void
Unsubscribes from the channel identified by name.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
private(String name) → BroadcastChannel
Returns a private BroadcastChannel for name.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited