feat(misskey-js): allow setting binaryType of WebSocket connection (#15190)

Co-authored-by: cannorin <cannorin@users.noreply.github.com>
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
cannorin
2025-01-14 21:20:24 +09:00
committed by GitHub
parent ed43cd87c9
commit 319f7e6a86
3 changed files with 10 additions and 0 deletions

View File

@@ -54,6 +54,7 @@ export default class Stream extends EventEmitter<StreamEvents> implements IStrea
constructor(origin: string, user: { token: string; } | null, options?: {
WebSocket?: Options['WebSocket'];
binaryType?: ReconnectingWebSocket['binaryType'];
}) {
super();
@@ -86,6 +87,9 @@ export default class Stream extends EventEmitter<StreamEvents> implements IStrea
minReconnectionDelay: 1, // https://github.com/pladaria/reconnecting-websocket/issues/91
WebSocket: options.WebSocket,
});
if (options.binaryType) {
this.stream.binaryType = options.binaryType;
}
this.stream.addEventListener('open', this.onOpen);
this.stream.addEventListener('close', this.onClose);
this.stream.addEventListener('message', this.onMessage);