dispatch method

void dispatch(
  1. String channel,
  2. String event,
  3. Map<String, dynamic> data
)

Deliver data to the handler registered for event on channel, exactly as the driver would on an incoming frame.

This is what turns "a handler exists" into "a handler runs on a frame". data is handed over already decoded, matching BroadcastEvent.data on the real driver, which performs the Pusher double-JSON-decode before a handler ever sees it.

Throws AssertionError if no handler is registered, because dispatching into silence is the failure this method exists to make visible.

Implementation

void dispatch(String channel, String event, Map<String, dynamic> data) {
  assertListening(channel, event);

  _driver._listeners[channel]![event]!(
    BroadcastEvent(
      event: event,
      channel: channel,
      data: data,
      receivedAt: DateTime.now(),
    ),
  );
}