Skip to content

Commit 7aa646e

Browse files
Fix WS notifier (#206)
## Description Apply the same fix to the notifier websocket as in #194 Closes FCE-2115 ## Motivation and Context The websocket doesn't work on node ## Documentation impact - [ ] Documentation update required - [ ] Documentation updated [in another PR](_) - [ ] No documentation update required ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
1 parent 1c93dbf commit 7aa646e

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/js-server-sdk/src/ws_notifier.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ export class FishjamWSNotifier extends (EventEmitter as new () => TypedEmitter<N
8484

8585
this.client = new WebSocket(websocketUrl);
8686

87+
this.client.binaryType = 'arraybuffer';
88+
8789
this.client.onerror = (message) => onError(message);
8890
this.client.onclose = (message) => onClose(message.code, message.reason);
8991
this.client.onmessage = (message) => this.dispatchNotification(message);
@@ -92,7 +94,8 @@ export class FishjamWSNotifier extends (EventEmitter as new () => TypedEmitter<N
9294

9395
private dispatchNotification(message: MessageEvent) {
9496
try {
95-
const decodedMessage = ServerMessage.decode(message.data);
97+
const data = new Uint8Array(message.data);
98+
const decodedMessage = ServerMessage.decode(data);
9699
const [notification, msg] = Object.entries(decodedMessage).find(([_k, v]) => v)!;
97100

98101
if (!this.isExpectedEvent(notification)) return;

0 commit comments

Comments
 (0)