@@ -9,9 +9,6 @@ horizontal scalability, automatic JSON encoding/decoding, and more.
9
9
10
10
npm install socket.io
11
11
12
- ** Note:** this is the documentation for the upcoming release ** 0.7** . The latest
13
- tag on NPM is [ 0.6] ( https://github.com/LearnBoost/Socket.IO-node/tree/06 ) .
14
-
15
12
## How to use
16
13
17
14
First, require ` socket.io ` :
@@ -30,7 +27,10 @@ var app = express.createServer();
30
27
app .listen (80 );
31
28
32
29
io .sockets .on (' connection' , function (socket ) {
33
- socket .send ({ hello: ' world' });
30
+ socket .emit (' news' , { hello: ' world' });
31
+ socket .on (' my other event' , function (data ) {
32
+ console .log (data);
33
+ });
34
34
});
35
35
```
36
36
@@ -40,8 +40,9 @@ Finally, load it from the client side code:
40
40
<script src =" /socket.io/socket.io.js" ></script >
41
41
<script >
42
42
var socket = io .connect (' http://localhost' );
43
- socket .on (' news' , function () {
44
- socket .emit (' myOtherEvent' , { my: ' data' });
43
+ socket .on (' news' , function (data ) {
44
+ console .log (data);
45
+ socket .emit (' my other event' , { my: ' data' });
45
46
});
46
47
</script >
47
48
```
@@ -318,8 +319,6 @@ io.configure('development', function () {
318
319
});
319
320
` ` `
320
321
321
- ## [API docs](http://socket.io/api.html)
322
-
323
322
## License
324
323
325
324
(The MIT License)
0 commit comments