@@ -202,21 +202,65 @@ server.listen(3000);
202
202
Hash of ` Socket` objects that are connected to this namespace indexed
203
203
by ` id` .
204
204
205
+ ### Namespace#use(fn:Function):Namespace
206
+
207
+ Registers a middleware, which is a function that gets executed for
208
+ every incoming ` Socket` and receives as parameter the socket and a
209
+ function to optionally defer execution to the next registered
210
+ middleware.
211
+
212
+ ` ` `
213
+ var io = require (' socket.io' )();
214
+ io .use (function (socket , next ){
215
+ if (socket .request .headers .cookie ) return next ();
216
+ done (new Error (' Authentication error' ));
217
+ });
218
+ ` ` `
219
+
220
+ Errors passed to middleware callbacks are sent as special ` error`
221
+ packets to clients.
222
+
205
223
### Socket
206
224
207
225
A ` Socket` is the fundamental class for interacting with browser
208
- clients.
226
+ clients. A ` Socket` belongs to a certain ` Namespace` (by default ` / ` )
227
+ and uses an underlying ` Client` to communicate.
209
228
210
229
### Socket#rooms:Array
211
230
212
231
A list of strings identifying the rooms this socket is in.
213
232
233
+ ### Socket#client:Client
234
+
235
+ A reference to the underlying ` Client` object.
236
+
237
+ ### Socket#conn:Socket
238
+
239
+ A reference to the underyling ` Client` transport connection (engine.io
240
+ ` Socket` object).
241
+
242
+ ### Socket#request:Request
243
+
244
+ A getter proxy that returns the reference to the ` request` that
245
+ originated the underlying engine.io ` Client` . Useful for accessing
246
+ request headers such as ` Cookie` or ` User- Agent` .
247
+
214
248
### Client
215
249
216
250
The ` Client` class represents an incoming transport (engine.io)
217
251
connection. A ` Client` can be associated with many multiplexed ` Socket`
218
252
that belong to different ` Namespace` s.
219
253
254
+ ### Client#conn
255
+
256
+ A reference to the underlying ` engine .io ` ` Socket` connection.
257
+
258
+ ### Client#request
259
+
260
+ A getter proxy that returns the reference to the ` request` that
261
+ originated the engine.io connection. Useful for accessing
262
+ request headers such as ` Cookie` or ` User- Agent` .
263
+
220
264
### Adapter
221
265
222
266
The ` Adapter` is in charge of keeping track of what rooms each socket
0 commit comments