Skip to content

Commit

Permalink
feat(misskey-js): allow setting binaryType of WebSocket connection
Browse files Browse the repository at this point in the history
  • Loading branch information
cannorin committed Dec 29, 2024
1 parent 3c81926 commit eaef109
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
- Fix: 起動前の疎通チェックが機能しなくなっていた問題を修正
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/737)

### Misskey.js
- Feat: allow setting `binaryType` of WebSocket connection

## 2024.11.0

Expand Down
1 change: 1 addition & 0 deletions packages/misskey-js/etc/misskey-js.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3151,6 +3151,7 @@ export class Stream extends EventEmitter<StreamEvents> implements IStream {
token: string;
} | null, options?: {
WebSocket?: _ReconnectingWebsocket.Options['WebSocket'];
binaryType?: _ReconnectingWebsocket.default['binaryType'];
});
// (undocumented)
close(): void;
Expand Down
4 changes: 4 additions & 0 deletions packages/misskey-js/src/streaming.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default class Stream extends EventEmitter<StreamEvents> implements IStrea

constructor(origin: string, user: { token: string; } | null, options?: {
WebSocket?: _ReconnectingWebsocket.Options['WebSocket'];
binaryType?: _ReconnectingWebsocket.default['binaryType'];
}) {
super();

Expand Down Expand Up @@ -84,6 +85,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);
Expand Down

0 comments on commit eaef109

Please sign in to comment.