node-pluginsmanager-plugin 6.5.0 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +13 -13
- package/README.md +53 -48
- package/lib/@types/socket.io-v2.d.ts +988 -0
- package/lib/cjs/checkers/RangeError/checkNonEmptyNumber.d.ts +2 -2
- package/lib/cjs/checkers/RangeError/checkNonEmptyObject.d.ts +2 -2
- package/lib/cjs/checkers/RangeError/checkNonEmptyString.d.ts +2 -2
- package/lib/cjs/checkers/ReferenceError/checkExists.d.ts +2 -2
- package/lib/cjs/checkers/TypeError/checkFunction.d.ts +2 -2
- package/lib/cjs/checkers/TypeError/checkInteger.d.ts +2 -2
- package/lib/cjs/checkers/TypeError/checkNumber.d.ts +2 -2
- package/lib/cjs/checkers/TypeError/checkObject.d.ts +2 -2
- package/lib/cjs/checkers/TypeError/checkString.d.ts +2 -2
- package/lib/cjs/components/DescriptorUser.d.ts +10 -11
- package/lib/cjs/components/DescriptorUser.js +51 -40
- package/lib/cjs/components/Mediator.d.ts +12 -17
- package/lib/cjs/components/Mediator.js +59 -39
- package/lib/cjs/components/MediatorUser.d.ts +2 -2
- package/lib/cjs/components/MediatorUser.js +12 -5
- package/lib/cjs/components/Orchestrator.d.ts +13 -13
- package/lib/cjs/components/Orchestrator.js +123 -69
- package/lib/cjs/components/Server.d.ts +22 -19
- package/lib/cjs/components/Server.js +279 -238
- package/lib/cjs/main.cjs +1 -40
- package/lib/cjs/main.d.cts +3 -15
- package/lib/cjs/openAPITypes.d.ts +5 -0
- package/lib/cjs/openAPITypes.js +3 -0
- package/lib/cjs/utils/cleanSendedError.d.ts +1 -1
- package/lib/cjs/utils/cleanSendedError.js +2 -4
- package/lib/cjs/utils/descriptor/extractParams.d.ts +1 -1
- package/lib/cjs/utils/descriptor/extractParams.js +1 -1
- package/lib/cjs/utils/descriptor/extractPathMethodByOperationId.d.ts +2 -3
- package/lib/cjs/utils/descriptor/extractPathMethodByOperationId.js +14 -14
- package/lib/cjs/utils/descriptor/extractPattern.d.ts +2 -2
- package/lib/cjs/utils/descriptor/extractPattern.js +5 -5
- package/lib/cjs/utils/descriptor/extractSchemaType.d.ts +1 -1
- package/lib/cjs/utils/descriptor/extractSchemaType.js +13 -8
- package/lib/cjs/utils/file/readJSONFile.d.ts +1 -1
- package/lib/cjs/utils/request/extractBody.js +9 -5
- package/lib/cjs/utils/request/extractCookies.d.ts +1 -1
- package/lib/cjs/utils/request/extractCookies.js +6 -6
- package/lib/cjs/utils/request/extractIp.d.ts +1 -1
- package/lib/cjs/utils/request/extractIp.js +19 -10
- package/lib/cjs/utils/request/extractMime.d.ts +1 -4
- package/lib/cjs/utils/request/extractMime.js +15 -11
- package/lib/cjs/utils/send.d.ts +4 -4
- package/lib/cjs/utils/send.js +27 -29
- package/lib/cjs/utils/server/getServerTypeFromServer.d.ts +4 -0
- package/lib/cjs/utils/server/getServerTypeFromServer.js +23 -0
- package/lib/cjs/utils/server/getSocketIOVersionFromServer.d.ts +4 -0
- package/lib/cjs/utils/server/getSocketIOVersionFromServer.js +19 -0
- package/package.json +101 -97
- package/lib/cjs/checkers/RangeError/checkArrayLength.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkArrayLength.js +0 -23
- package/lib/cjs/checkers/RangeError/checkArrayLengthBetween.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkArrayLengthBetween.js +0 -30
- package/lib/cjs/checkers/RangeError/checkIntegerBetween.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkIntegerBetween.js +0 -29
- package/lib/cjs/checkers/RangeError/checkNonEmptyArray.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkNonEmptyArray.js +0 -19
- package/lib/cjs/checkers/RangeError/checkNonEmptyInteger.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkNonEmptyInteger.js +0 -19
- package/lib/cjs/checkers/RangeError/checkNumberBetween.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkNumberBetween.js +0 -29
- package/lib/cjs/checkers/RangeError/checkObjectLength.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkObjectLength.js +0 -28
- package/lib/cjs/checkers/RangeError/checkObjectLengthBetween.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkObjectLengthBetween.js +0 -33
- package/lib/cjs/checkers/RangeError/checkStringLength.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkStringLength.js +0 -23
- package/lib/cjs/checkers/RangeError/checkStringLengthBetween.d.ts +0 -2
- package/lib/cjs/checkers/RangeError/checkStringLengthBetween.js +0 -30
- package/lib/cjs/checkers/TypeError/checkArray.d.ts +0 -2
- package/lib/cjs/checkers/TypeError/checkArray.js +0 -19
- package/lib/cjs/checkers/TypeError/checkBoolean.d.ts +0 -2
- package/lib/cjs/checkers/TypeError/checkBoolean.js +0 -19
- package/lib/cjs/utils/jsonParser.d.ts +0 -1
- package/lib/cjs/utils/jsonParser.js +0 -16
|
@@ -0,0 +1,988 @@
|
|
|
1
|
+
// Type definitions for socket.io 2.1
|
|
2
|
+
// https://npmjs.com/package/@types/socket.io
|
|
3
|
+
// npm:@types/socket.io@^2.1.13
|
|
4
|
+
// Project: http://socket.io/
|
|
5
|
+
// Definitions by: PROGRE <https://github.com/progre>
|
|
6
|
+
// Damian Connolly <https://github.com/divillysausages>
|
|
7
|
+
// Florent Poujol <https://github.com/florentpoujol>
|
|
8
|
+
// KentarouTakeda <https://github.com/KentarouTakeda>
|
|
9
|
+
// Alexey Snigirev <https://github.com/gigi>
|
|
10
|
+
// Ezinwa Okpoechi <https://github.com/BrainMaestro>
|
|
11
|
+
// Marek Urbanowicz <https://github.com/murbanowicz>
|
|
12
|
+
// Kevin Kam <https://github.com/kevinkam>
|
|
13
|
+
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
14
|
+
|
|
15
|
+
///<reference types="node" />
|
|
16
|
+
///<reference lib="dom" />
|
|
17
|
+
|
|
18
|
+
declare const SocketIO: SocketIOStatic;
|
|
19
|
+
import engine = require('engine.io');
|
|
20
|
+
import { Server as HttpServer, IncomingMessage } from 'http';
|
|
21
|
+
import { Server as HttpsServer } from 'https';
|
|
22
|
+
import { Encoder as ParserEncoder, Decoder as ParserDecoder } from 'socket.io-parser';
|
|
23
|
+
export = SocketIO;
|
|
24
|
+
/** @deprecated Available as a global for backwards-compatibility. */
|
|
25
|
+
export as namespace SocketIO;
|
|
26
|
+
|
|
27
|
+
type tFunction = (...args: unknown[]) => void;
|
|
28
|
+
|
|
29
|
+
interface SocketIOStatic {
|
|
30
|
+
/**
|
|
31
|
+
* Default Server constructor
|
|
32
|
+
*/
|
|
33
|
+
(): SocketIO.Server;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new Server
|
|
37
|
+
* @param srv The HTTP server that we're going to bind to
|
|
38
|
+
* @param opts An optional parameters object
|
|
39
|
+
*/
|
|
40
|
+
(srv: HttpServer | HttpsServer, opts?: SocketIO.ServerOptions): SocketIO.Server;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Creates a new Server
|
|
44
|
+
* @param port A port to bind to, as a number, or a string
|
|
45
|
+
* @param An optional parameters object
|
|
46
|
+
*/
|
|
47
|
+
(port: string | number, opts?: SocketIO.ServerOptions): SocketIO.Server;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Creates a new Server
|
|
51
|
+
* @param A parameters object
|
|
52
|
+
*/
|
|
53
|
+
(opts: SocketIO.ServerOptions): SocketIO.Server;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Default Server constructor
|
|
57
|
+
*/
|
|
58
|
+
new (): SocketIO.Server;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Creates a new Server
|
|
62
|
+
* @param srv The HTTP server that we're going to bind to
|
|
63
|
+
* @param opts An optional parameters object
|
|
64
|
+
*/
|
|
65
|
+
new (srv: HttpServer | HttpsServer, opts?: SocketIO.ServerOptions): SocketIO.Server;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Creates a new Server
|
|
69
|
+
* @param port A port to bind to, as a number, or a string
|
|
70
|
+
* @param An optional parameters object
|
|
71
|
+
*/
|
|
72
|
+
new (port: string | number, opts?: SocketIO.ServerOptions): SocketIO.Server;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Creates a new Server
|
|
76
|
+
* @param A parameters object
|
|
77
|
+
*/
|
|
78
|
+
new (opts: SocketIO.ServerOptions): SocketIO.Server;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Backwards compatibility
|
|
82
|
+
* @see io().listen()
|
|
83
|
+
*/
|
|
84
|
+
listen: SocketIOStatic;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
declare namespace SocketIO {
|
|
88
|
+
interface Server {
|
|
89
|
+
engine: { ws: any, generateId: (id: IncomingMessage) => string };
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* A dictionary of all the namespaces currently on this Server
|
|
93
|
+
*/
|
|
94
|
+
nsps: { [namespace: string]: Namespace };
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The default '/' Namespace
|
|
98
|
+
*/
|
|
99
|
+
sockets: Namespace;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Sets the 'json' flag when emitting an event
|
|
103
|
+
*/
|
|
104
|
+
json: Server;
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Sets a modifier for a subsequent event emission that the event data may be lost if the clients are not ready to receive messages
|
|
108
|
+
*/
|
|
109
|
+
volatile: Server;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Sets a modifier for a subsequent event emission that the event data will only be broadcast to the current node
|
|
113
|
+
*/
|
|
114
|
+
local: Server;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Server request verification function, that checks for allowed origins
|
|
118
|
+
* @param req The http.IncomingMessage request
|
|
119
|
+
* @param fn The callback to be called. It should take one parameter, err,
|
|
120
|
+
* which will be null if there was no problem, and one parameter, success,
|
|
121
|
+
* of type boolean
|
|
122
|
+
*/
|
|
123
|
+
checkRequest(req: any, fn: (err: any, success: boolean) => void): void;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Gets whether we're serving the client.js file or not
|
|
127
|
+
* @default true
|
|
128
|
+
*/
|
|
129
|
+
serveClient(): boolean;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Sets whether we're serving the client.js file or not
|
|
133
|
+
* @param v True if we want to serve the file, false otherwise
|
|
134
|
+
* @default true
|
|
135
|
+
* @return This Server
|
|
136
|
+
*/
|
|
137
|
+
serveClient(v: boolean): Server;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Gets the client serving path
|
|
141
|
+
* @default '/socket.io'
|
|
142
|
+
*/
|
|
143
|
+
path(): string;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Sets the client serving path
|
|
147
|
+
* @param v The path to serve the client file on
|
|
148
|
+
* @default '/socket.io'
|
|
149
|
+
* @return This Server
|
|
150
|
+
*/
|
|
151
|
+
path(v: string): Server;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Gets the adapter that we're going to use for handling rooms
|
|
155
|
+
* @default typeof Adapter
|
|
156
|
+
*/
|
|
157
|
+
adapter(): any;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Sets the adapter (class) that we're going to use for handling rooms
|
|
161
|
+
* @param v The class for the adapter to create
|
|
162
|
+
* @default typeof Adapter
|
|
163
|
+
* @return This Server
|
|
164
|
+
*/
|
|
165
|
+
adapter(v: any): Server;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Gets the allowed origins for requests
|
|
169
|
+
* @default "*:*"
|
|
170
|
+
*/
|
|
171
|
+
origins(): string | string[];
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Sets the allowed origins for requests
|
|
175
|
+
* @param v The allowed origins, in host:port form
|
|
176
|
+
* @default "*:*"
|
|
177
|
+
* return This Server
|
|
178
|
+
*/
|
|
179
|
+
origins(v: string | string[]): Server;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Provides a function taking two arguments origin:String
|
|
183
|
+
* and callback(error, success), where success is a boolean
|
|
184
|
+
* value indicating whether origin is allowed or not. If
|
|
185
|
+
* success is set to false, error must be provided as a string
|
|
186
|
+
* value that will be appended to the server response, e.g. “Origin not allowed”.
|
|
187
|
+
* @param fn The function that will be called to check the origin
|
|
188
|
+
* return This Server
|
|
189
|
+
*/
|
|
190
|
+
origins(fn: (origin: string, callback: (error: string | null, success: boolean) => void) => void): Server;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Attaches socket.io to a server
|
|
194
|
+
* @param srv The http.Server that we want to attach to
|
|
195
|
+
* @param opts An optional parameters object
|
|
196
|
+
* @return This Server
|
|
197
|
+
*/
|
|
198
|
+
attach(srv: HttpServer | HttpsServer, opts?: ServerOptions): Server;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Attaches socket.io to a port
|
|
202
|
+
* @param port The port that we want to attach to
|
|
203
|
+
* @param opts An optional parameters object
|
|
204
|
+
* @return This Server
|
|
205
|
+
*/
|
|
206
|
+
attach(port: number, opts?: ServerOptions): Server;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* @see attach( srv, opts )
|
|
210
|
+
*/
|
|
211
|
+
listen(srv: HttpServer | HttpsServer, opts?: ServerOptions): Server;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* @see attach( port, opts )
|
|
215
|
+
*/
|
|
216
|
+
listen(port: number, opts?: ServerOptions): Server;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Binds socket.io to an engine.io instance
|
|
220
|
+
* @param src The Engine.io (or compatible) server to bind to
|
|
221
|
+
* @return This Server
|
|
222
|
+
*/
|
|
223
|
+
bind(srv: any): Server;
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Called with each incoming connection
|
|
227
|
+
* @param socket The Engine.io Socket
|
|
228
|
+
* @return This Server
|
|
229
|
+
*/
|
|
230
|
+
onconnection(socket: any): Server;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Looks up/creates a Namespace
|
|
234
|
+
* @param nsp The name of the NameSpace to look up/create. Should start
|
|
235
|
+
* with a '/'
|
|
236
|
+
* @return The Namespace
|
|
237
|
+
*/
|
|
238
|
+
of(nsp: string | RegExp | tFunction): Namespace;
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Closes the server connection
|
|
242
|
+
*/
|
|
243
|
+
close(fn?: () => void): void;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* The event fired when we get a new connection
|
|
247
|
+
* @param event The event being fired: 'connection'
|
|
248
|
+
* @param listener A listener that should take one parameter of type Socket
|
|
249
|
+
* @return The default '/' Namespace
|
|
250
|
+
*/
|
|
251
|
+
on(event: 'connection', listener: (socket: Socket) => void): Namespace;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* @see on( 'connection', listener )
|
|
255
|
+
*/
|
|
256
|
+
on(event: 'connect', listener: (socket: Socket) => void): Namespace;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Base 'on' method to add a listener for an event
|
|
260
|
+
* @param event The event that we want to add a listener for
|
|
261
|
+
* @param listener The callback to call when we get the event. The parameters
|
|
262
|
+
* for the callback depend on the event
|
|
263
|
+
* @return The default '/' Namespace
|
|
264
|
+
*/
|
|
265
|
+
on(event: string, listener: tFunction): Namespace;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Targets a room when emitting to the default '/' Namespace
|
|
269
|
+
* @param room The name of the room that we're targeting
|
|
270
|
+
* @return The default '/' Namespace
|
|
271
|
+
*/
|
|
272
|
+
to(room: string): Namespace;
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* @see to( room )
|
|
276
|
+
*/
|
|
277
|
+
in(room: string): Namespace;
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Registers a middleware function, which is a function that gets executed
|
|
281
|
+
* for every incoming Socket, on the default '/' Namespace
|
|
282
|
+
* @param fn The function to call when we get a new incoming socket. It should
|
|
283
|
+
* take one parameter of type Socket, and one callback function to call to
|
|
284
|
+
* execute the next middleware function. The callback can take one optional
|
|
285
|
+
* parameter, err, if there was an error. Errors passed to middleware callbacks
|
|
286
|
+
* are sent as special 'error' packets to clients
|
|
287
|
+
* @return The default '/' Namespace
|
|
288
|
+
*/
|
|
289
|
+
use(fn: (socket: Socket, fn: (err?: any) => void) => void): Namespace;
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Emits an event to the default Namespace
|
|
293
|
+
* @param event The event that we want to emit
|
|
294
|
+
* @param args Any number of optional arguments to pass with the event. If the
|
|
295
|
+
* last argument is a function, it will be called as an ack. The ack should
|
|
296
|
+
* take whatever data was sent with the packet
|
|
297
|
+
* @return The default '/' Namespace
|
|
298
|
+
*/
|
|
299
|
+
emit(event: string, ...args: any[]): Namespace;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Sends a 'message' event
|
|
303
|
+
* @see emit( event, ...args )
|
|
304
|
+
* @return The default '/' Namespace
|
|
305
|
+
*/
|
|
306
|
+
send(...args: any[]): Namespace;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* @see send( ...args )
|
|
310
|
+
*/
|
|
311
|
+
write(...args: any[]): Namespace;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Gets a list of clients
|
|
315
|
+
* @return The default '/' Namespace
|
|
316
|
+
*/
|
|
317
|
+
clients(...args: any[]): Namespace;
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Sets the compress flag
|
|
321
|
+
* @return The default '/' Namespace
|
|
322
|
+
*/
|
|
323
|
+
compress(...args: any[]): Namespace;
|
|
324
|
+
|
|
325
|
+
// Socket inherits the following methods from NodeJS.EventEmitter
|
|
326
|
+
// https://github.com/socketio/socket.io/blob/2.1.1/lib/socket.js#L81
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Alias for `on`
|
|
330
|
+
* @param event The event that we want to add a listener for
|
|
331
|
+
* @param listener The callback to call when we get the event. The parameters
|
|
332
|
+
* for the callback depend on the event
|
|
333
|
+
* @return The default '/' Namespace
|
|
334
|
+
*
|
|
335
|
+
* _Inherited from EventEmitter - https://nodejs.org/api/events.html_
|
|
336
|
+
*/
|
|
337
|
+
addListener(event: string, listener: (...args: any[]) => void): Namespace;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Adds a one-time listener for an event
|
|
341
|
+
* @param event The event that we want to add a listener for
|
|
342
|
+
* @param listener The callback to call when we get the event. The parameters
|
|
343
|
+
* for the callback depend on the event
|
|
344
|
+
* @return The default '/' Namespace
|
|
345
|
+
*
|
|
346
|
+
* _Inherited from EventEmitter - https://nodejs.org/api/events.html_
|
|
347
|
+
*/
|
|
348
|
+
once(event: string, listener: (...args: any[]) => void): Namespace;
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Removes a specific listener for an event
|
|
352
|
+
* @param event The event that we want to add a listener for
|
|
353
|
+
* @param listener The callback to remove from the event event. Must be
|
|
354
|
+
* the exact function reference that was added
|
|
355
|
+
* @return The default '/' Namespace
|
|
356
|
+
*
|
|
357
|
+
* _Inherited from EventEmitter - https://nodejs.org/api/events.html_
|
|
358
|
+
*/
|
|
359
|
+
removeListener(event: string, listener: (...args: any[]) => void): Namespace;
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Alias for `removeListener`
|
|
363
|
+
* @param event The event that we want to add a listener for
|
|
364
|
+
* @param listener The callback to remove from the event event. Must be
|
|
365
|
+
* the exact function reference that was added
|
|
366
|
+
* @return The default '/' Namespace
|
|
367
|
+
*
|
|
368
|
+
* _Inherited from EventEmitter - https://nodejs.org/api/events.html_
|
|
369
|
+
*/
|
|
370
|
+
off(event: string, listener: (...args: any[]) => void): Namespace;
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Removes all listeners, or those of the specified event
|
|
374
|
+
* @param event The event to remove all listeners for, if omitted
|
|
375
|
+
* all events will be removed
|
|
376
|
+
* @return The default '/' Namespace
|
|
377
|
+
*
|
|
378
|
+
* _Inherited from EventEmitter - https://nodejs.org/api/events.html_
|
|
379
|
+
*/
|
|
380
|
+
removeAllListeners(event?: string): Namespace;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Sets the max amount of event listeners
|
|
384
|
+
* @param n The max amount of allowed event listeners.
|
|
385
|
+
* @return The default '/' Namespace
|
|
386
|
+
*
|
|
387
|
+
* _Inherited from EventEmitter - https://nodejs.org/api/events.html_
|
|
388
|
+
*/
|
|
389
|
+
setMaxListeners(n: number): Namespace;
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Gets the max amount of event listeners
|
|
393
|
+
* @return The max amount of allowed event listeners.
|
|
394
|
+
*
|
|
395
|
+
* _Inherited from EventEmitter - https://nodejs.org/api/events.html_
|
|
396
|
+
*/
|
|
397
|
+
getMaxListeners(): number;
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Gets a copy of all listeners for an event.
|
|
401
|
+
* @param event The event to retrieve all listeners for
|
|
402
|
+
* @return A copy of the array of listeners for the event
|
|
403
|
+
*
|
|
404
|
+
* _Inherited from EventEmitter - https://nodejs.org/api/events.html_
|
|
405
|
+
*/
|
|
406
|
+
listeners(event: string): tFunction[];
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* Get a copy of all listeners for an event, including one-time events.
|
|
410
|
+
* @param event The event to retrieve all listeners for
|
|
411
|
+
* @return A copy of the array of listeners for the event,
|
|
412
|
+
* including any wrappers (such as those created by .once()).
|
|
413
|
+
*
|
|
414
|
+
* _Inherited from EventEmitter - https://nodejs.org/api/events.html_
|
|
415
|
+
*/
|
|
416
|
+
rawListeners(event: string): tFunction[];
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Gets the number of listeners listening to the event.
|
|
420
|
+
* @param event The event to retrieve the total listener count for
|
|
421
|
+
* @return The total number of listeners listening to the event
|
|
422
|
+
*
|
|
423
|
+
* _Inherited from EventEmitter - https://nodejs.org/api/events.html_
|
|
424
|
+
*/
|
|
425
|
+
listenerCount(type: string): number;
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Adds the listener function to the _beginning_ of the listeners array for the event
|
|
429
|
+
* @param event The event that we want to add a listener for
|
|
430
|
+
* @param listener The callback to call when we get the event. The parameters
|
|
431
|
+
* for the callback depend on the event
|
|
432
|
+
* @return The default '/' Namespace
|
|
433
|
+
*
|
|
434
|
+
* _Inherited from EventEmitter - https://nodejs.org/api/events.html_
|
|
435
|
+
*/
|
|
436
|
+
prependListener(event: string, listener: (...args: any[]) => void): Namespace;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Adds a one-time listener function to the _beginning_ of the listeners array for the event
|
|
440
|
+
* @param event The event that we want to add a listener for
|
|
441
|
+
* @param listener The callback to call when we get the event. The parameters
|
|
442
|
+
* for the callback depend on the event
|
|
443
|
+
* @return The default '/' Namespace
|
|
444
|
+
*
|
|
445
|
+
* _Inherited from EventEmitter - https://nodejs.org/api/events.html_
|
|
446
|
+
*/
|
|
447
|
+
prependOnceListener(event: string, listener: (...args: any[]) => void): Namespace;
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Gets an array of events for which listeners have been registered
|
|
451
|
+
* @param event The event that we want to add a listener for
|
|
452
|
+
* @return An array listing the events for which the emitter has registered listeners
|
|
453
|
+
*
|
|
454
|
+
* _Inherited from EventEmitter - https://nodejs.org/api/events.html_
|
|
455
|
+
*/
|
|
456
|
+
eventNames(): string[];
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Options to pass to our server when creating it
|
|
461
|
+
*/
|
|
462
|
+
interface ServerOptions extends engine.AttachOptions {
|
|
463
|
+
/**
|
|
464
|
+
* The path to server the client file to.
|
|
465
|
+
* @default '/socket.io'
|
|
466
|
+
*/
|
|
467
|
+
path?: string;
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Should we serve the client file?
|
|
471
|
+
* @default true
|
|
472
|
+
*/
|
|
473
|
+
serveClient?: boolean;
|
|
474
|
+
|
|
475
|
+
/**
|
|
476
|
+
* The adapter to use for handling rooms. NOTE: this should be a class,
|
|
477
|
+
* not an object.
|
|
478
|
+
* @default typeof Adapter
|
|
479
|
+
*/
|
|
480
|
+
adapter?: Adapter;
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Accepted origins.
|
|
484
|
+
* @default '*:*'
|
|
485
|
+
*/
|
|
486
|
+
origins?: string | string[];
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* The parser to use. Defaults to an instance of the `Parser` that
|
|
490
|
+
* ships with socket.io which is memory-based. See `socket.io-parser`.
|
|
491
|
+
* @default require('socket.io-parser')
|
|
492
|
+
*/
|
|
493
|
+
parser?: {
|
|
494
|
+
Encoder: ParserEncoder,
|
|
495
|
+
Decoder: ParserDecoder,
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* The Namespace, sandboxed environments for sockets, each connection
|
|
501
|
+
* to a Namespace requires a new Socket
|
|
502
|
+
*/
|
|
503
|
+
interface Namespace extends NodeJS.EventEmitter {
|
|
504
|
+
/**
|
|
505
|
+
* The name of the NameSpace
|
|
506
|
+
*/
|
|
507
|
+
name: string;
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* The controller Server for this Namespace
|
|
511
|
+
*/
|
|
512
|
+
server: Server;
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* A dictionary of all the Sockets connected to this Namespace, where
|
|
516
|
+
* the Socket ID is the key
|
|
517
|
+
*/
|
|
518
|
+
sockets: { [id: string]: Socket };
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* A dictionary of all the Sockets connected to this Namespace, where
|
|
522
|
+
* the Socket ID is the key
|
|
523
|
+
*/
|
|
524
|
+
connected: { [id: string]: Socket };
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* The Adapter that we're using to handle dealing with rooms etc
|
|
528
|
+
*/
|
|
529
|
+
adapter: Adapter;
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Sets the 'json' flag when emitting an event
|
|
533
|
+
*/
|
|
534
|
+
json: Namespace;
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Registers a middleware function, which is a function that gets executed
|
|
538
|
+
* for every incoming Socket
|
|
539
|
+
* @param fn The function to call when we get a new incoming socket. It should
|
|
540
|
+
* take one parameter of type Socket, and one callback function to call to
|
|
541
|
+
* execute the next middleware function. The callback can take one optional
|
|
542
|
+
* parameter, err, if there was an error. Errors passed to middleware callbacks
|
|
543
|
+
* are sent as special 'error' packets to clients
|
|
544
|
+
* @return This Namespace
|
|
545
|
+
*/
|
|
546
|
+
use(fn: (socket: Socket, fn: (err?: any) => void) => void): Namespace;
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Targets a room when emitting
|
|
550
|
+
* @param room The name of the room that we're targeting
|
|
551
|
+
* @return This Namespace
|
|
552
|
+
*/
|
|
553
|
+
to(room: string): Namespace;
|
|
554
|
+
|
|
555
|
+
/**
|
|
556
|
+
* @see to( room )
|
|
557
|
+
*/
|
|
558
|
+
in(room: string): Namespace;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Sends a 'message' event
|
|
562
|
+
* @see emit( event, ...args )
|
|
563
|
+
* @return This Namespace
|
|
564
|
+
*/
|
|
565
|
+
send(...args: any[]): Namespace;
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* @see send( ...args )
|
|
569
|
+
*/
|
|
570
|
+
write(...args: any[]): Namespace;
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* The event fired when we get a new connection
|
|
574
|
+
* @param event The event being fired: 'connection'
|
|
575
|
+
* @param listener A listener that should take one parameter of type Socket
|
|
576
|
+
* @return This Namespace
|
|
577
|
+
*/
|
|
578
|
+
on(event: 'connection', listener: (socket: Socket) => void): this;
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* @see on( 'connection', listener )
|
|
582
|
+
*/
|
|
583
|
+
on(event: 'connect', listener: (socket: Socket) => void): this;
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Base 'on' method to add a listener for an event
|
|
587
|
+
* @param event The event that we want to add a listener for
|
|
588
|
+
* @param listener The callback to call when we get the event. The parameters
|
|
589
|
+
* for the callback depend on the event
|
|
590
|
+
* @ This Namespace
|
|
591
|
+
*/
|
|
592
|
+
on(event: string, listener: tFunction): this;
|
|
593
|
+
|
|
594
|
+
/**
|
|
595
|
+
* Gets a list of clients.
|
|
596
|
+
* @return This Namespace
|
|
597
|
+
*/
|
|
598
|
+
clients(fn: tFunction): Namespace;
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Sets the compress flag.
|
|
602
|
+
* @param compress If `true`, compresses the sending data
|
|
603
|
+
* @return This Namespace
|
|
604
|
+
*/
|
|
605
|
+
compress(compress: boolean): Namespace;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
interface Packet extends Array<any> {
|
|
609
|
+
/**
|
|
610
|
+
* Event name
|
|
611
|
+
*/
|
|
612
|
+
[0]: string;
|
|
613
|
+
/**
|
|
614
|
+
* Packet data
|
|
615
|
+
*/
|
|
616
|
+
[1]: any;
|
|
617
|
+
/**
|
|
618
|
+
* Ack function
|
|
619
|
+
*/
|
|
620
|
+
[2]: (...args: any[]) => void;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* The socket, which handles our connection for a namespace. NOTE: while
|
|
625
|
+
* we technically extend NodeJS.EventEmitter, we're not putting it here
|
|
626
|
+
* as we have a problem with the emit() event (as it's overridden with a
|
|
627
|
+
* different return)
|
|
628
|
+
*/
|
|
629
|
+
interface Socket extends NodeJS.EventEmitter {
|
|
630
|
+
/**
|
|
631
|
+
* The namespace that this socket is for
|
|
632
|
+
*/
|
|
633
|
+
nsp: Namespace;
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* The Server that our namespace is in
|
|
637
|
+
*/
|
|
638
|
+
server: Server;
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* The Adapter that we use to handle our rooms
|
|
642
|
+
*/
|
|
643
|
+
adapter: Adapter;
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* The unique ID for this Socket. Regenerated at every connection. This is
|
|
647
|
+
* also the name of the room that the Socket automatically joins on connection
|
|
648
|
+
*/
|
|
649
|
+
id: string;
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* The http.IncomingMessage request sent with the connection. Useful
|
|
653
|
+
* for recovering headers etc
|
|
654
|
+
*/
|
|
655
|
+
request: any;
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* The Client associated with this Socket
|
|
659
|
+
*/
|
|
660
|
+
client: Client;
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* The underlying Engine.io Socket instance
|
|
664
|
+
*/
|
|
665
|
+
conn: EngineSocket;
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* The list of rooms that this Socket is currently in, where
|
|
669
|
+
* the ID the the room ID
|
|
670
|
+
*/
|
|
671
|
+
rooms: { [id: string]: string };
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Is the Socket currently connected?
|
|
675
|
+
*/
|
|
676
|
+
connected: boolean;
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Is the Socket currently disconnected?
|
|
680
|
+
*/
|
|
681
|
+
disconnected: boolean;
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* The object used when negociating the handshake
|
|
685
|
+
*/
|
|
686
|
+
handshake: Handshake;
|
|
687
|
+
/**
|
|
688
|
+
* Sets the 'json' flag when emitting an event
|
|
689
|
+
*/
|
|
690
|
+
json: Socket;
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* Sets the 'volatile' flag when emitting an event. Volatile messages are
|
|
694
|
+
* messages that can be dropped because of network issues and the like. Use
|
|
695
|
+
* for high-volume/real-time messages where you don't need to receive *all*
|
|
696
|
+
* of them
|
|
697
|
+
*/
|
|
698
|
+
volatile: Socket;
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Sets the 'broadcast' flag when emitting an event. Broadcasting an event
|
|
702
|
+
* will send it to all the other sockets in the namespace except for yourself
|
|
703
|
+
*/
|
|
704
|
+
broadcast: Socket;
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* Targets a room when broadcasting
|
|
708
|
+
* @param room The name of the room that we're targeting
|
|
709
|
+
* @return This Socket
|
|
710
|
+
*/
|
|
711
|
+
to(room: string): Socket;
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* @see to( room )
|
|
715
|
+
*/
|
|
716
|
+
in(room: string): Socket;
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Registers a middleware, which is a function that gets executed for every incoming Packet and receives as parameter the packet and a function to optionally defer execution to the next registered middleware.
|
|
720
|
+
*
|
|
721
|
+
* Errors passed to middleware callbacks are sent as special error packets to clients.
|
|
722
|
+
*/
|
|
723
|
+
use(fn: (packet: Packet, next: (err?: any) => void) => void): Socket;
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* Sends a 'message' event
|
|
727
|
+
* @see emit( event, ...args )
|
|
728
|
+
*/
|
|
729
|
+
send(...args: any[]): Socket;
|
|
730
|
+
|
|
731
|
+
/**
|
|
732
|
+
* @see send( ...args )
|
|
733
|
+
*/
|
|
734
|
+
write(...args: any[]): Socket;
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Joins a room. You can join multiple rooms, and by default, on connection,
|
|
738
|
+
* you join a room with the same name as your ID
|
|
739
|
+
* @param name The name of the room that we want to join
|
|
740
|
+
* @param fn An optional callback to call when we've joined the room. It should
|
|
741
|
+
* take an optional parameter, err, of a possible error
|
|
742
|
+
* @return This Socket
|
|
743
|
+
*/
|
|
744
|
+
join(name: string | string[], fn?: (err?: any) => void): Socket;
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* Leaves a room
|
|
748
|
+
* @param name The name of the room to leave
|
|
749
|
+
* @param fn An optional callback to call when we've left the room. It should
|
|
750
|
+
* take on optional parameter, err, of a possible error
|
|
751
|
+
*/
|
|
752
|
+
leave(name: string, fn?: tFunction): Socket;
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* Leaves all the rooms that we've joined
|
|
756
|
+
*/
|
|
757
|
+
leaveAll(): void;
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Disconnects this Socket
|
|
761
|
+
* @param close If true, also closes the underlying connection
|
|
762
|
+
* @return This Socket
|
|
763
|
+
*/
|
|
764
|
+
disconnect(close?: boolean): Socket;
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Returns all the callbacks for a particular event
|
|
768
|
+
* @param event The event that we're looking for the callbacks of
|
|
769
|
+
* @return An array of callback Functions, or an empty array if we don't have any
|
|
770
|
+
*/
|
|
771
|
+
listeners(event: string): tFunction[];
|
|
772
|
+
|
|
773
|
+
/**
|
|
774
|
+
* Sets the compress flag
|
|
775
|
+
* @param compress If `true`, compresses the sending data
|
|
776
|
+
* @return This Socket
|
|
777
|
+
*/
|
|
778
|
+
compress(compress: boolean): Socket;
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Emits the error
|
|
782
|
+
* @param err Error message=
|
|
783
|
+
*/
|
|
784
|
+
error(err: any): void;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
interface Handshake {
|
|
788
|
+
/**
|
|
789
|
+
* The headers passed along with the request. e.g. 'host',
|
|
790
|
+
* 'connection', 'accept', 'referer', 'cookie'
|
|
791
|
+
*/
|
|
792
|
+
headers: any;
|
|
793
|
+
|
|
794
|
+
/**
|
|
795
|
+
* The authentication payload
|
|
796
|
+
*/
|
|
797
|
+
auth: { token: string };
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* The current time, as a string
|
|
801
|
+
*/
|
|
802
|
+
time: string;
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* The remote address of the connection request
|
|
806
|
+
*/
|
|
807
|
+
address: string;
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* Is this a cross-domain request?
|
|
811
|
+
*/
|
|
812
|
+
xdomain: boolean;
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Is this a secure request?
|
|
816
|
+
*/
|
|
817
|
+
secure: boolean;
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* The timestamp for when this was issued
|
|
821
|
+
*/
|
|
822
|
+
issued: number;
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* The request url
|
|
826
|
+
*/
|
|
827
|
+
url: string;
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Any query string parameters in the request url
|
|
831
|
+
*/
|
|
832
|
+
query: Record<string, string>;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* The interface describing a room
|
|
837
|
+
*/
|
|
838
|
+
interface Room {
|
|
839
|
+
sockets: { [id: string]: boolean };
|
|
840
|
+
length: number;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/**
|
|
844
|
+
* The interface describing a dictionary of rooms
|
|
845
|
+
* Where room is the name of the room
|
|
846
|
+
*/
|
|
847
|
+
|
|
848
|
+
interface Rooms {
|
|
849
|
+
[room: string]: Room;
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
/**
|
|
853
|
+
* The interface used when dealing with rooms etc
|
|
854
|
+
*/
|
|
855
|
+
interface Adapter extends NodeJS.EventEmitter {
|
|
856
|
+
/**
|
|
857
|
+
* The namespace that this adapter is for
|
|
858
|
+
*/
|
|
859
|
+
nsp: Namespace;
|
|
860
|
+
|
|
861
|
+
/**
|
|
862
|
+
* A dictionary of all the rooms that we have in this namespace
|
|
863
|
+
*/
|
|
864
|
+
rooms: Rooms;
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* A dictionary of all the socket ids that we're dealing with, and all
|
|
868
|
+
* the rooms that the socket is currently in
|
|
869
|
+
*/
|
|
870
|
+
sids: { [id: string]: { [room: string]: boolean } };
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* Adds a socket to a room. If the room doesn't exist, it's created
|
|
874
|
+
* @param id The ID of the socket to add
|
|
875
|
+
* @param room The name of the room to add the socket to
|
|
876
|
+
* @param callback An optional callback to call when the socket has been
|
|
877
|
+
* added. It should take an optional parameter, error, if there was a problem
|
|
878
|
+
*/
|
|
879
|
+
add(id: string, room: string, callback?: (err?: any) => void): void;
|
|
880
|
+
|
|
881
|
+
/**
|
|
882
|
+
* Removes a socket from a room. If there are no more sockets in the room,
|
|
883
|
+
* the room is deleted
|
|
884
|
+
* @param id The ID of the socket that we're removing
|
|
885
|
+
* @param room The name of the room to remove the socket from
|
|
886
|
+
* @param callback An optional callback to call when the socket has been
|
|
887
|
+
* removed. It should take on optional parameter, error, if there was a problem
|
|
888
|
+
*/
|
|
889
|
+
del(id: string, room: string, callback?: (err?: any) => void): void;
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* Removes a socket from all the rooms that it's joined
|
|
893
|
+
* @param id The ID of the socket that we're removing
|
|
894
|
+
*/
|
|
895
|
+
delAll(id: string): void;
|
|
896
|
+
|
|
897
|
+
/**
|
|
898
|
+
* Broadcasts a packet
|
|
899
|
+
* @param packet The packet to broadcast
|
|
900
|
+
* @param opts Any options to send along:
|
|
901
|
+
* - rooms: An optional list of rooms to broadcast to. If empty, the packet is broadcast to all sockets
|
|
902
|
+
* - except: A list of Socket IDs to exclude
|
|
903
|
+
* - flags: Any flags that we want to send along ('json', 'volatile', 'broadcast')
|
|
904
|
+
*/
|
|
905
|
+
broadcast(
|
|
906
|
+
packet: any,
|
|
907
|
+
opts: { rooms?: string[]; except?: string[]; flags?: { [flag: string]: boolean } },
|
|
908
|
+
): void;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* The client behind each socket (can have multiple sockets)
|
|
913
|
+
*/
|
|
914
|
+
interface Client {
|
|
915
|
+
/**
|
|
916
|
+
* The Server that this client belongs to
|
|
917
|
+
*/
|
|
918
|
+
server: Server;
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* The underlying Engine.io Socket instance
|
|
922
|
+
*/
|
|
923
|
+
conn: EngineSocket;
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* The ID for this client. Regenerated at every connection
|
|
927
|
+
*/
|
|
928
|
+
id: string;
|
|
929
|
+
|
|
930
|
+
/**
|
|
931
|
+
* The http.IncomingMessage request sent with the connection. Useful
|
|
932
|
+
* for recovering headers etc
|
|
933
|
+
*/
|
|
934
|
+
request: any;
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* The dictionary of sockets currently connect via this client (i.e. to different
|
|
938
|
+
* namespaces) where the Socket ID is the key
|
|
939
|
+
*/
|
|
940
|
+
sockets: { [id: string]: Socket };
|
|
941
|
+
|
|
942
|
+
/**
|
|
943
|
+
* A dictionary of all the namespaces for this client, with the Socket that
|
|
944
|
+
* deals with that namespace
|
|
945
|
+
*/
|
|
946
|
+
nsps: { [nsp: string]: Socket };
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/**
|
|
950
|
+
* A reference to the underlying engine.io Socket connection.
|
|
951
|
+
*/
|
|
952
|
+
interface EngineSocket extends NodeJS.EventEmitter {
|
|
953
|
+
/**
|
|
954
|
+
* The ID for this socket - matches Client.id
|
|
955
|
+
*/
|
|
956
|
+
id: string;
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
* The Engine.io Server for this socket
|
|
960
|
+
*/
|
|
961
|
+
server: any;
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* The ready state for the client. Either 'opening', 'open', 'closing', or 'closed'
|
|
965
|
+
*/
|
|
966
|
+
readyState: string;
|
|
967
|
+
|
|
968
|
+
/**
|
|
969
|
+
* The remote IP for this connection
|
|
970
|
+
*/
|
|
971
|
+
remoteAddress: string;
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* whether the transport has been upgraded
|
|
975
|
+
*/
|
|
976
|
+
upgraded: boolean;
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* (http.IncomingMessage): request that originated the Socket
|
|
980
|
+
*/
|
|
981
|
+
request: any;
|
|
982
|
+
|
|
983
|
+
/**
|
|
984
|
+
* (Transport): transport reference
|
|
985
|
+
*/
|
|
986
|
+
transport: any;
|
|
987
|
+
}
|
|
988
|
+
}
|