*Update types and add new bound versions
This commit is contained in:
parent
b9611cecd7
commit
ae2ee61bec
23
src/peer.ts
23
src/peer.ts
|
@ -10,11 +10,24 @@ export type OnOpen = (
|
||||||
| Promise<{ connect: boolean }>
|
| Promise<{ connect: boolean }>
|
||||||
| Promise<void>
|
| Promise<void>
|
||||||
| void;
|
| void;
|
||||||
export type OnData = (data: any) => void;
|
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 OnOpenBound = (
|
||||||
|
socket: Socket,
|
||||||
|
data: any
|
||||||
|
) =>
|
||||||
|
| { connect: boolean }
|
||||||
|
| Promise<{ connect: boolean }>
|
||||||
|
| Promise<void>
|
||||||
|
| void;
|
||||||
|
export type OnDataBound = (data: any) => void;
|
||||||
|
export type OnReceiveBound = OnDataBound;
|
||||||
|
export type OnCloseBound = OnDataBound;
|
||||||
|
export type OnSendBound = OnDataBound;
|
||||||
|
|
||||||
export interface DataSocketOptions {
|
export interface DataSocketOptions {
|
||||||
onopen?: OnOpen;
|
onopen?: OnOpen;
|
||||||
onreceive?: OnReceive;
|
onreceive?: OnReceive;
|
||||||
|
@ -37,10 +50,10 @@ export default class Peer {
|
||||||
private _peer: any;
|
private _peer: any;
|
||||||
private _muxer: any;
|
private _muxer: any;
|
||||||
private _socket?: Socket;
|
private _socket?: Socket;
|
||||||
private _onopen: OnOpen;
|
private _onopen: OnOpenBound;
|
||||||
private _onreceive: OnReceive;
|
private _onreceive: OnReceiveBound;
|
||||||
private _onsend: OnSend;
|
private _onsend: OnSendBound;
|
||||||
private _onclose: OnClose;
|
private _onclose: OnCloseBound;
|
||||||
private _emulateWebsocket: boolean;
|
private _emulateWebsocket: boolean;
|
||||||
|
|
||||||
private _channel?: any;
|
private _channel?: any;
|
||||||
|
|
Loading…
Reference in New Issue