Compare commits
No commits in common. "41984ae5882fbfb9e3cd63519e20b9fc3fab63c5" and "b14509d6f18124bffdf201766aadaa984922fabb" have entirely different histories.
41984ae588
...
b14509d6f1
|
@ -9,7 +9,6 @@ export type OnData = (peer: Peer, data: any) => void;
|
||||||
export type OnReceive = OnData;
|
export type OnReceive = OnData;
|
||||||
export type OnClose = OnData;
|
export type OnClose = OnData;
|
||||||
export type OnSend = OnData;
|
export type OnSend = OnData;
|
||||||
export type OnChannel = (peer: Peer, channel: any) => void;
|
|
||||||
export type OnOpenBound = (socket: Socket, data: any) => {
|
export type OnOpenBound = (socket: Socket, data: any) => {
|
||||||
connect: boolean;
|
connect: boolean;
|
||||||
} | Promise<{
|
} | Promise<{
|
||||||
|
@ -19,13 +18,11 @@ export type OnDataBound = (data: any) => void;
|
||||||
export type OnReceiveBound = OnDataBound;
|
export type OnReceiveBound = OnDataBound;
|
||||||
export type OnCloseBound = OnDataBound;
|
export type OnCloseBound = OnDataBound;
|
||||||
export type OnSendBound = OnDataBound;
|
export type OnSendBound = OnDataBound;
|
||||||
export type OnChannelBound = (channel: any) => void;
|
|
||||||
export interface DataSocketOptions {
|
export interface DataSocketOptions {
|
||||||
onopen?: OnOpen;
|
onopen?: OnOpen;
|
||||||
onreceive?: OnReceive;
|
onreceive?: OnReceive;
|
||||||
onsend?: OnSend;
|
onsend?: OnSend;
|
||||||
onclose?: OnClose;
|
onclose?: OnClose;
|
||||||
onchannel?: OnChannel;
|
|
||||||
emulateWebsocket?: boolean;
|
emulateWebsocket?: boolean;
|
||||||
}
|
}
|
||||||
export interface PeerOptions {
|
export interface PeerOptions {
|
||||||
|
@ -44,9 +41,8 @@ export default class Peer {
|
||||||
private _onreceive;
|
private _onreceive;
|
||||||
private _onsend;
|
private _onsend;
|
||||||
private _onclose;
|
private _onclose;
|
||||||
private _onchannel;
|
|
||||||
private _emulateWebsocket;
|
private _emulateWebsocket;
|
||||||
constructor({ proxy, peer, muxer, onopen, onreceive, onsend, onclose, onchannel, emulateWebsocket, }: PeerOptionsWithProxy & DataSocketOptions);
|
constructor({ proxy, peer, muxer, onopen, onreceive, onsend, onclose, emulateWebsocket, }: PeerOptionsWithProxy & DataSocketOptions);
|
||||||
private _channel?;
|
private _channel?;
|
||||||
get channel(): any;
|
get channel(): any;
|
||||||
init(): Promise<void>;
|
init(): Promise<void>;
|
||||||
|
|
|
@ -14,9 +14,8 @@ class Peer {
|
||||||
_onreceive;
|
_onreceive;
|
||||||
_onsend;
|
_onsend;
|
||||||
_onclose;
|
_onclose;
|
||||||
_onchannel;
|
|
||||||
_emulateWebsocket;
|
_emulateWebsocket;
|
||||||
constructor({ proxy, peer, muxer, onopen, onreceive, onsend, onclose, onchannel, emulateWebsocket = false, }) {
|
constructor({ proxy, peer, muxer, onopen, onreceive, onsend, onclose, emulateWebsocket = false, }) {
|
||||||
this._proxy = proxy;
|
this._proxy = proxy;
|
||||||
this._peer = peer;
|
this._peer = peer;
|
||||||
this._muxer = muxer;
|
this._muxer = muxer;
|
||||||
|
@ -24,7 +23,6 @@ class Peer {
|
||||||
this._onreceive = onreceive?.bind(undefined, this);
|
this._onreceive = onreceive?.bind(undefined, this);
|
||||||
this._onsend = onsend?.bind(undefined, this);
|
this._onsend = onsend?.bind(undefined, this);
|
||||||
this._onclose = onclose?.bind(undefined, this);
|
this._onclose = onclose?.bind(undefined, this);
|
||||||
this._onchannel = onchannel?.bind(undefined, this);
|
|
||||||
this._emulateWebsocket = emulateWebsocket;
|
this._emulateWebsocket = emulateWebsocket;
|
||||||
}
|
}
|
||||||
_channel;
|
_channel;
|
||||||
|
@ -76,7 +74,6 @@ class Peer {
|
||||||
await self._onreceive?.(m);
|
await self._onreceive?.(m);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
await this._onchannel?.(this._channel);
|
|
||||||
await this._channel.open();
|
await this._channel.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ export default class Proxy {
|
||||||
private _listen;
|
private _listen;
|
||||||
private _socketOptions;
|
private _socketOptions;
|
||||||
private _autostart;
|
private _autostart;
|
||||||
constructor({ swarm, protocol, onopen, onreceive, onsend, onclose, onchannel, listen, autostart, emulateWebsocket, }: ProxyOptions);
|
constructor({ swarm, protocol, onopen, onreceive, onsend, onclose, listen, autostart, emulateWebsocket, }: ProxyOptions);
|
||||||
private _swarm;
|
private _swarm;
|
||||||
get swarm(): any;
|
get swarm(): any;
|
||||||
private _protocol;
|
private _protocol;
|
||||||
|
|
|
@ -9,7 +9,7 @@ class Proxy {
|
||||||
_listen;
|
_listen;
|
||||||
_socketOptions;
|
_socketOptions;
|
||||||
_autostart;
|
_autostart;
|
||||||
constructor({ swarm, protocol, onopen, onreceive, onsend, onclose, onchannel, listen = false, autostart = false, emulateWebsocket = false, }) {
|
constructor({ swarm, protocol, onopen, onreceive, onsend, onclose, listen = false, autostart = false, emulateWebsocket = false, }) {
|
||||||
this._swarm = swarm;
|
this._swarm = swarm;
|
||||||
this._protocol = protocol;
|
this._protocol = protocol;
|
||||||
this._listen = listen;
|
this._listen = listen;
|
||||||
|
@ -19,7 +19,6 @@ class Proxy {
|
||||||
onreceive,
|
onreceive,
|
||||||
onsend,
|
onsend,
|
||||||
onclose,
|
onclose,
|
||||||
onchannel,
|
|
||||||
emulateWebsocket,
|
emulateWebsocket,
|
||||||
};
|
};
|
||||||
this.init();
|
this.init();
|
||||||
|
|
|
@ -14,7 +14,6 @@ export type OnData = (peer: Peer, data: any) => void;
|
||||||
export type OnReceive = OnData;
|
export type OnReceive = OnData;
|
||||||
export type OnClose = OnData;
|
export type OnClose = OnData;
|
||||||
export type OnSend = OnData;
|
export type OnSend = OnData;
|
||||||
export type OnChannel = (peer: Peer, channel: any) => void;
|
|
||||||
|
|
||||||
export type OnOpenBound = (
|
export type OnOpenBound = (
|
||||||
socket: Socket,
|
socket: Socket,
|
||||||
|
@ -29,14 +28,11 @@ export type OnReceiveBound = OnDataBound;
|
||||||
export type OnCloseBound = OnDataBound;
|
export type OnCloseBound = OnDataBound;
|
||||||
export type OnSendBound = OnDataBound;
|
export type OnSendBound = OnDataBound;
|
||||||
|
|
||||||
export type OnChannelBound = (channel: any) => void;
|
|
||||||
|
|
||||||
export interface DataSocketOptions {
|
export interface DataSocketOptions {
|
||||||
onopen?: OnOpen;
|
onopen?: OnOpen;
|
||||||
onreceive?: OnReceive;
|
onreceive?: OnReceive;
|
||||||
onsend?: OnSend;
|
onsend?: OnSend;
|
||||||
onclose?: OnClose;
|
onclose?: OnClose;
|
||||||
onchannel?: OnChannel;
|
|
||||||
emulateWebsocket?: boolean;
|
emulateWebsocket?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +54,6 @@ export default class Peer {
|
||||||
private _onreceive: OnReceiveBound;
|
private _onreceive: OnReceiveBound;
|
||||||
private _onsend: OnSendBound;
|
private _onsend: OnSendBound;
|
||||||
private _onclose: OnCloseBound;
|
private _onclose: OnCloseBound;
|
||||||
private _onchannel: OnChannelBound;
|
|
||||||
private _emulateWebsocket: boolean;
|
private _emulateWebsocket: boolean;
|
||||||
|
|
||||||
constructor({
|
constructor({
|
||||||
|
@ -69,7 +64,6 @@ export default class Peer {
|
||||||
onreceive,
|
onreceive,
|
||||||
onsend,
|
onsend,
|
||||||
onclose,
|
onclose,
|
||||||
onchannel,
|
|
||||||
emulateWebsocket = false,
|
emulateWebsocket = false,
|
||||||
}: PeerOptionsWithProxy & DataSocketOptions) {
|
}: PeerOptionsWithProxy & DataSocketOptions) {
|
||||||
this._proxy = proxy;
|
this._proxy = proxy;
|
||||||
|
@ -79,7 +73,6 @@ export default class Peer {
|
||||||
this._onreceive = onreceive?.bind(undefined, this);
|
this._onreceive = onreceive?.bind(undefined, this);
|
||||||
this._onsend = onsend?.bind(undefined, this);
|
this._onsend = onsend?.bind(undefined, this);
|
||||||
this._onclose = onclose?.bind(undefined, this);
|
this._onclose = onclose?.bind(undefined, this);
|
||||||
this._onchannel = onchannel?.bind(undefined, this);
|
|
||||||
this._emulateWebsocket = emulateWebsocket;
|
this._emulateWebsocket = emulateWebsocket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +130,6 @@ export default class Peer {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
await this._onchannel?.(this._channel);
|
|
||||||
await this._channel.open();
|
await this._channel.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,6 @@ export default class Proxy {
|
||||||
onreceive,
|
onreceive,
|
||||||
onsend,
|
onsend,
|
||||||
onclose,
|
onclose,
|
||||||
onchannel,
|
|
||||||
listen = false,
|
listen = false,
|
||||||
autostart = false,
|
autostart = false,
|
||||||
emulateWebsocket = false,
|
emulateWebsocket = false,
|
||||||
|
@ -34,7 +33,6 @@ export default class Proxy {
|
||||||
onreceive,
|
onreceive,
|
||||||
onsend,
|
onsend,
|
||||||
onclose,
|
onclose,
|
||||||
onchannel,
|
|
||||||
emulateWebsocket,
|
emulateWebsocket,
|
||||||
};
|
};
|
||||||
this.init();
|
this.init();
|
||||||
|
|
Loading…
Reference in New Issue