Skip to main content
Version: 0.28.0

Function: decodeServerNotifications()

decodeServerNotifications(data): ServerNotification[]

Defined in: js-server-sdk/src/webhook.ts:31

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

ParameterType
dataArrayBuffer | Uint8Array<ArrayBufferLike>

Returns

ServerNotification[]

Example

for (const { type, notification } of decodeServerNotifications(body)) { if (type === 'peerConnected') handlePeerConnected(notification); }