connectWebhookStream function

WebhookListener connectWebhookStream({
  1. required String apiKey,
  2. String baseUrl = 'https://kit.openiap.dev',
  3. Duration reconnectDelay = const Duration(seconds: 2),
  4. HttpClient? httpClient,
})

Open a long-lived listener against the kit SSE stream. The listener auto-reconnects with Last-Event-ID until close is called.

Implementation

WebhookListener connectWebhookStream({
  required String apiKey,
  String baseUrl = 'https://kit.openiap.dev',
  Duration reconnectDelay = const Duration(seconds: 2),
  HttpClient? httpClient,
}) {
  final listener = _SseWebhookListener(
    apiKey: apiKey,
    baseUrl: baseUrl,
    reconnectDelay: reconnectDelay,
    httpClient: httpClient,
  );
  // Fire-and-forget the loop; consumers gate via [close].
  // ignore: unawaited_futures
  listener.start();
  return listener;
}