diff --git a/lib/peer.ts b/lib/peer.ts index 37771bbca..b75b09ea7 100644 --- a/lib/peer.ts +++ b/lib/peer.ts @@ -28,6 +28,7 @@ class PeerOptions implements PeerJSOption { config?: any; secure?: boolean; pingInterval?: number; + protocol?: string | string[]; referrerPolicy?: ReferrerPolicy; logFunction?: (logLevel: LogLevel, ...rest: any[]) => void; } @@ -240,6 +241,7 @@ export class Peer extends EventEmitter { this._options.path!, this._options.key!, this._options.pingInterval, + this._options.protocol, ); socket.on(SocketEventType.Message, (data: ServerMessage) => { diff --git a/lib/socket.ts b/lib/socket.ts index e47cb5f25..c7d27af92 100644 --- a/lib/socket.ts +++ b/lib/socket.ts @@ -22,6 +22,7 @@ export class Socket extends EventEmitter { path: string, key: string, private readonly pingInterval: number = 5000, + private readonly protocol: string | string[] | undefined = undefined, ) { super(); @@ -39,7 +40,7 @@ export class Socket extends EventEmitter { return; } - this._socket = new WebSocket(wsUrl + "&version=" + version); + this._socket = new WebSocket(wsUrl + "&version=" + version, this.protocol); this._disconnected = false; this._socket.onmessage = (event) => {