@@ -16,9 +16,9 @@ HTTP server listening on port `3000`.
1616``` js
1717var server = require (' http' ).createServer ();
1818var io = require (' socket.io' )(server);
19- io .on (' connection' , function (socket ){
20- socket .on (' event' , function (data ){});
21- socket .on (' disconnect' , function (){});
19+ io .on (' connection' , function (client ){
20+ client .on (' event' , function (data ){});
21+ client .on (' disconnect' , function (){});
2222});
2323server .listen (3000 );
2424```
@@ -27,7 +27,7 @@ server.listen(3000);
2727
2828``` js
2929var io = require (' socket.io' )();
30- io .on (' connection' , function (socket ){});
30+ io .on (' connection' , function (client ){});
3131io .listen (3000 );
3232```
3333
@@ -200,7 +200,7 @@ server.listen(3000);
200200
201201### Server#close
202202
203- Closes socket server
203+ Closes socket.io server
204204
205205 ``` js
206206 var Server = require (' socket.io' );
@@ -300,10 +300,13 @@ server.listen(3000);
300300 A ` Socket ` is the fundamental class for interacting with browser
301301 clients. A ` Socket ` belongs to a certain ` Namespace ` (by default ` / ` )
302302 and uses an underlying ` Client ` to communicate.
303+
304+ It should be noted the ` Socket ` doesn't relate directly to the actual
305+ underlying TCP/IP ` socket ` and it is only the name of the class.
303306
304307### Socket#rooms: Object
305308
306- A hash of strings identifying the rooms this socket is in, indexed by
309+ A hash of strings identifying the rooms this client is in, indexed by
307310 room name.
308311
309312### Socket#client: Client
@@ -313,7 +316,8 @@ server.listen(3000);
313316### Socket#conn: Socket
314317
315318 A reference to the underlying ` Client ` transport connection (engine.io
316- ` Socket ` object).
319+ ` Socket ` object). This allows access to the IO transport layer, which
320+ still (mostly) asbtracts the actual TCP/IP socket.
317321
318322### Socket#request: Request
319323
@@ -323,30 +327,30 @@ server.listen(3000);
323327
324328### Socket#id: String
325329
326- A unique identifier for the socket session, that comes from the
330+ A unique identifier for the session, that comes from the
327331 underlying ` Client ` .
328332
329333### Socket#emit(name: String [ , …] ): Socket
330334
331- Emits an event to the socket identified by the string ` name ` . Any
332- other parameters can be included.
335+ Emits an event identified by the string ` name ` to the client.
336+ Any other parameters can be included.
333337
334338 All datastructures are supported, including ` Buffer ` . JavaScript
335339 functions can't be serialized/deserialized.
336340
337341 ``` js
338342 var io = require (' socket.io' )();
339- io .on (' connection' , function (socket ){
340- socket .emit (' an event' , { some: ' data' });
343+ io .on (' connection' , function (client ){
344+ client .emit (' an event' , { some: ' data' });
341345 });
342346 ```
343347
344348### Socket#join(name: String [ , fn: Function ] ): Socket
345349
346- Adds the socket to the ` room ` , and fires optionally a callback ` fn `
350+ Adds the client to the ` room ` , and fires optionally a callback ` fn `
347351 with ` err ` signature (if any).
348352
349- The socket is automatically a member of a room identified with its
353+ The client is automatically a member of a room identified with its
350354 session id (see ` Socket#id ` ).
351355
352356 The mechanics of joining rooms are handled by the ` Adapter `
@@ -355,7 +359,7 @@ server.listen(3000);
355359
356360### Socket#leave(name: String [ , fn: Function ] ): Socket
357361
358- Removes the socket from ` room ` , and fires optionally a callback ` fn `
362+ Removes the client from ` room ` , and fires optionally a callback ` fn `
359363 with ` err ` signature (if any).
360364
361365 ** Rooms are left automatically upon disconnection** .
@@ -367,14 +371,14 @@ server.listen(3000);
367371### Socket#to(room: String ): Socket
368372
369373 Sets a modifier for a subsequent event emission that the event will
370- only be _ broadcasted_ to sockets that have joined the given ` room ` .
374+ only be _ broadcasted_ to clients that have joined the given ` room ` .
371375
372376 To emit to multiple rooms, you can call ` to ` several times.
373377
374378 ``` js
375379 var io = require (' socket.io' )();
376- io .on (' connection' , function (socket ){
377- socket .to (' others' ).emit (' an event' , { some: ' data' });
380+ io .on (' connection' , function (client ){
381+ client .to (' others' ).emit (' an event' , { some: ' data' });
378382 });
379383 ```
380384
@@ -389,8 +393,8 @@ server.listen(3000);
389393
390394 ``` js
391395 var io = require (' socket.io' )();
392- io .on (' connection' , function (socket ){
393- socket .compress (false ).emit (' an event' , { some: ' data' });
396+ io .on (' connection' , function (client ){
397+ client .compress (false ).emit (' an event' , { some: ' data' });
394398 });
395399 ```
396400
0 commit comments