-
Notifications
You must be signed in to change notification settings - Fork 3k
/
manager.d.ts
203 lines (203 loc) · 4.45 KB
/
manager.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import Emitter from "component-emitter";
export declare class Manager extends Emitter {
autoConnect: boolean;
readyState: "opening" | "open" | "closed";
reconnecting: boolean;
private readonly uri;
private readonly opts;
private nsps;
private subs;
private backoff;
private _reconnection;
private _reconnectionAttempts;
private _reconnectionDelay;
private _randomizationFactor;
private _reconnectionDelayMax;
private _timeout;
private connecting;
private lastPing;
private encoding;
private packetBuffer;
private encoder;
private decoder;
private engine;
private skipReconnect;
/**
* `Manager` constructor.
*
* @param {String} engine instance or engine uri/opts
* @param {Object} options
* @api public
*/
constructor(uri: any, opts: any);
/**
* Propagate given event to sockets and emit on `this`
*
* @api private
*/
emitAll(event: string, arg?: any): void;
/**
* Update `socket.id` of all sockets
*
* @api private
*/
updateSocketIds(): void;
/**
* generate `socket.id` for the given `nsp`
*
* @param {String} nsp
* @return {String}
* @api private
*/
generateId(nsp: any): string;
/**
* Sets the `reconnection` config.
*
* @param {Boolean} true/false if it should automatically reconnect
* @return {Manager} self or value
* @api public
*/
reconnection(v?: any): boolean | this;
/**
* Sets the reconnection attempts config.
*
* @param {Number} max reconnection attempts before giving up
* @return {Manager} self or value
* @api public
*/
reconnectionAttempts(v?: any): number | this;
/**
* Sets the delay between reconnections.
*
* @param {Number} delay
* @return {Manager} self or value
* @api public
*/
reconnectionDelay(v?: any): number | this;
randomizationFactor(v?: any): number | this;
/**
* Sets the maximum delay between reconnections.
*
* @param {Number} delay
* @return {Manager} self or value
* @api public
*/
reconnectionDelayMax(v?: any): number | this;
/**
* Sets the connection timeout. `false` to disable
*
* @return {Manager} self or value
* @api public
*/
timeout(v?: any): any;
/**
* Starts trying to reconnect if reconnection is enabled and we have not
* started reconnecting yet
*
* @api private
*/
maybeReconnectOnOpen(): void;
/**
* Sets the current transport `socket`.
*
* @param {Function} optional, callback
* @return {Manager} self
* @api public
*/
open(fn?: any, opts?: any): this;
connect(fn: any, opts: any): this;
/**
* Called upon transport open.
*
* @api private
*/
onopen(): void;
/**
* Called upon a ping.
*
* @api private
*/
onping(): void;
/**
* Called upon a packet.
*
* @api private
*/
onpong(): void;
/**
* Called with data.
*
* @api private
*/
ondata(data: any): void;
/**
* Called when parser fully decodes a packet.
*
* @api private
*/
ondecoded(packet: any): void;
/**
* Called upon socket error.
*
* @api private
*/
onerror(err: any): void;
/**
* Creates a new socket for the given `nsp`.
*
* @return {Socket}
* @api public
*/
socket(nsp: any, opts: any): any;
/**
* Called upon a socket close.
*
* @param {Socket} socket
*/
destroy(socket: any): void;
/**
* Writes a packet.
*
* @param {Object} packet
* @api private
*/
packet(packet: any): void;
/**
* If packet buffer is non-empty, begins encoding the
* next packet in line.
*
* @api private
*/
processPacketQueue(): void;
/**
* Clean up transport subscriptions and packet buffer.
*
* @api private
*/
cleanup(): void;
/**
* Close the current socket.
*
* @api private
*/
close(): void;
disconnect(): void;
/**
* Called upon engine close.
*
* @api private
*/
onclose(reason: any): void;
/**
* Attempt a reconnection.
*
* @api private
*/
reconnect(): this;
/**
* Called upon successful reconnect.
*
* @api private
*/
onreconnect(): void;
}