Skip to content

Commit

Permalink
fix: fix WebSocket constructor chocking on empty protocol string
Browse files Browse the repository at this point in the history
fix WebSocket constructor chocking on empty protocol string
(phoboslab/jsmpeg@3afb0e5)
  • Loading branch information
cycjimmy committed Sep 5, 2022
1 parent 1d10489 commit 4caa818
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lib/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ export default class WSSource {
this.progress = 0;
this.established = false;

this.socket = new WebSocket(this.url, this.options.protocols || null);
if (this.options.protocols) {
this.socket = new WebSocket(this.url, this.options.protocols);
}
else {
this.socket = new WebSocket(this.url);
}
this.socket.binaryType = 'arraybuffer';
this.socket.onmessage = this.onMessage.bind(this);
this.socket.onopen = this.onOpen.bind(this);
Expand Down

0 comments on commit 4caa818

Please sign in to comment.