From bdacd018499516de290aacd1c0fd21f2afa4b93d Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 25 Feb 2023 22:16:40 -0500 Subject: [PATCH] *add emulateWebsocket to peer --- src/peer.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/peer.ts b/src/peer.ts index aa7e415..b27c0e8 100644 --- a/src/peer.ts +++ b/src/peer.ts @@ -19,6 +19,7 @@ export interface DataSocketOptions { onreceive?: OnReceive; onsend?: OnSend; onclose?: OnClose; + emulateWebsocket?: boolean; } export interface PeerOptions { @@ -39,6 +40,7 @@ export default class Peer { private _onreceive: OnReceive; private _onsend: OnSend; private _onclose: OnClose; + private _emulateWebsocket: boolean; constructor({ proxy, @@ -48,6 +50,7 @@ export default class Peer { onreceive, onsend, onclose, + emulateWebsocket = false, }: PeerOptionsWithProxy & DataSocketOptions) { this._proxy = proxy; this._peer = peer; @@ -56,6 +59,7 @@ export default class Peer { this._onreceive = onreceive; this._onsend = onsend; this._onclose = onclose; + this._emulateWebsocket = emulateWebsocket; } async init() { @@ -80,6 +84,7 @@ export default class Peer { remotePort: self._peer.rawStream.remotePort, remotePublicKey: self._peer.remotePublicKey, write, + emulateWebsocket: self._emulateWebsocket, }); self._socket.on("end", () => channel.close()); let ret = await self._onopen?.(self._socket, m);