*add emulateWebsocket to peer
This commit is contained in:
parent
603d7c4e14
commit
bdacd01849
|
@ -19,6 +19,7 @@ export interface DataSocketOptions {
|
||||||
onreceive?: OnReceive;
|
onreceive?: OnReceive;
|
||||||
onsend?: OnSend;
|
onsend?: OnSend;
|
||||||
onclose?: OnClose;
|
onclose?: OnClose;
|
||||||
|
emulateWebsocket?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PeerOptions {
|
export interface PeerOptions {
|
||||||
|
@ -39,6 +40,7 @@ export default class Peer {
|
||||||
private _onreceive: OnReceive;
|
private _onreceive: OnReceive;
|
||||||
private _onsend: OnSend;
|
private _onsend: OnSend;
|
||||||
private _onclose: OnClose;
|
private _onclose: OnClose;
|
||||||
|
private _emulateWebsocket: boolean;
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
proxy,
|
proxy,
|
||||||
|
@ -48,6 +50,7 @@ export default class Peer {
|
||||||
onreceive,
|
onreceive,
|
||||||
onsend,
|
onsend,
|
||||||
onclose,
|
onclose,
|
||||||
|
emulateWebsocket = false,
|
||||||
}: PeerOptionsWithProxy & DataSocketOptions) {
|
}: PeerOptionsWithProxy & DataSocketOptions) {
|
||||||
this._proxy = proxy;
|
this._proxy = proxy;
|
||||||
this._peer = peer;
|
this._peer = peer;
|
||||||
|
@ -56,6 +59,7 @@ export default class Peer {
|
||||||
this._onreceive = onreceive;
|
this._onreceive = onreceive;
|
||||||
this._onsend = onsend;
|
this._onsend = onsend;
|
||||||
this._onclose = onclose;
|
this._onclose = onclose;
|
||||||
|
this._emulateWebsocket = emulateWebsocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
|
@ -80,6 +84,7 @@ export default class Peer {
|
||||||
remotePort: self._peer.rawStream.remotePort,
|
remotePort: self._peer.rawStream.remotePort,
|
||||||
remotePublicKey: self._peer.remotePublicKey,
|
remotePublicKey: self._peer.remotePublicKey,
|
||||||
write,
|
write,
|
||||||
|
emulateWebsocket: self._emulateWebsocket,
|
||||||
});
|
});
|
||||||
self._socket.on("end", () => channel.close());
|
self._socket.on("end", () => channel.close());
|
||||||
let ret = await self._onopen?.(self._socket, m);
|
let ret = await self._onopen?.(self._socket, m);
|
||||||
|
|
Loading…
Reference in New Issue