@fishjam-cloud/js-server-sdk - v0.29.0-rc.2
    Preparing search index...

    Function decodeServerNotifications

    • Decode a raw Fishjam webhook body (application/x-protobuf) into typed, mapped notifications.

      A room/stream created with batchWebhookNotifications: true may deliver several notifications coalesced into a single NotificationBatch; this helper transparently unwraps that batch, so a single message and a batch are handled the same way. Notifications are returned in wire order, with the same payload mapping the FishjamWSNotifier applies (branded ids, peerType/track enums). Non-surfaced variants (handshake, deprecated) are omitted.

      Accepts a Node Buffer (a Uint8Array subclass), a Uint8Array, or an ArrayBuffer.

      Parameters

      • data: ArrayBuffer | Uint8Array<ArrayBufferLike>

      Returns ServerNotification[]

      import { decodeServerNotifications } from '@fishjam-cloud/js-server-sdk';

      declare const body: Uint8Array;
      declare const handlePeerConnected: (notification: unknown) => void;
      // ---cut---
      for (const { type, notification } of decodeServerNotifications(body)) {
      if (type === 'peerConnected') handlePeerConnected(notification);
      }