@@ -19,10 +19,10 @@ standalone build you can use as follows:
19
19
<script src =" /path/to/engine.io.js" ></script >
20
20
<script >
21
21
// eio = Socket
22
- var socket = eio (' ws://localhost' );
23
- socket .on (' open' , function () {
24
- socket .on (' message' , function (data ){});
25
- socket .on (' close' , function () {});
22
+ const socket = eio (' ws://localhost' );
23
+ socket .on (' open' , () => {
24
+ socket .on (' message' , (data ) => {});
25
+ socket .on (' close' , () => {});
26
26
});
27
27
</script >
28
28
```
@@ -41,10 +41,10 @@ Engine.IO is a commonjs module, which means you can include it by using
41
41
1. write your app code
42
42
43
43
` ` ` js
44
- var socket = require(' engine.io-client' )(' ws://localhost' );
45
- socket.on(' open' , function () {
46
- socket.on(' message' , function (data){});
47
- socket.on(' close' , function () {});
44
+ const socket = require(' engine.io-client' )(' ws://localhost' );
45
+ socket.on('open', () = > {
46
+ socket.on(' message' , (data) = > {});
47
+ socket.on('close', () = > {});
48
48
});
49
49
` ` `
50
50
@@ -65,12 +65,12 @@ Engine.IO is a commonjs module, which means you can include it by using
65
65
` ` ` html
66
66
< script src=" /path/to/engine.io.js" ></script>
67
67
< script>
68
- var socket = new eio.Socket(' ws://localhost/' );
68
+ const socket = new eio.Socket(' ws://localhost/' );
69
69
socket.binaryType = ' blob' ;
70
- socket.on(' open' , function () {
70
+ socket.on('open', () = > {
71
71
socket.send(new Int8Array(5));
72
- socket.on(' message' , function (blob){});
73
- socket.on(' close' , function (){ });
72
+ socket.on(' message' , (blob) = > {});
73
+ socket.on('close', () = > { });
74
74
});
75
75
< /script>
76
76
` ` `
@@ -80,41 +80,41 @@ Engine.IO is a commonjs module, which means you can include it by using
80
80
Add ` engine.io-client` to your ` package.json` and then:
81
81
82
82
` ` ` js
83
- var socket = require(' engine.io-client' )(' ws://localhost' );
84
- socket.on(' open' , function () {
85
- socket.on(' message' , function (data){});
86
- socket.on(' close' , function () {});
83
+ const socket = require(' engine.io-client' )(' ws://localhost' );
84
+ socket.on('open', () = > {
85
+ socket.on(' message' , (data) = > {});
86
+ socket.on('close', () = > {});
87
87
});
88
88
` ` `
89
89
90
90
# ## Node.js with certificates
91
91
` ` ` js
92
- var opts = {
92
+ const opts = {
93
93
key: fs.readFileSync(' test/fixtures/client.key' ),
94
94
cert: fs.readFileSync(' test/fixtures/client.crt' ),
95
95
ca: fs.readFileSync(' test/fixtures/ca.crt' )
96
96
};
97
97
98
- var socket = require(' engine.io-client' )(' ws://localhost' , opts);
99
- socket.on(' open' , function () {
100
- socket.on(' message' , function (data){});
101
- socket.on(' close' , function () {});
98
+ const socket = require(' engine.io-client' )(' ws://localhost' , opts);
99
+ socket.on('open', () = > {
100
+ socket.on(' message' , (data) = > {});
101
+ socket.on('close', () = > {});
102
102
});
103
103
` ` `
104
104
105
105
# ## Node.js with extraHeaders
106
106
` ` ` js
107
- var opts = {
107
+ const opts = {
108
108
extraHeaders: {
109
109
' X-Custom-Header-For-My-Project' : ' my-secret-access-token' ,
110
110
' Cookie' : ' user_session=NI2JlCKF90aE0sJZD9ZzujtdsUqNYSBYxzlTsvdSUe35ZzdtVRGqYFr0kdGxbfc5gUOkR9RGp20GVKza; path=/; expires=Tue, 07-Apr-2015 18:18:08 GMT; secure; HttpOnly'
111
111
}
112
112
};
113
113
114
- var socket = require(' engine.io-client' )(' ws://localhost' , opts);
115
- socket.on(' open' , function () {
116
- socket.on(' message' , function (data){});
117
- socket.on(' close' , function () {});
114
+ const socket = require(' engine.io-client' )(' ws://localhost' , opts);
115
+ socket.on('open', () = > {
116
+ socket.on(' message' , (data) = > {});
117
+ socket.on('close', () = > {});
118
118
});
119
119
` ` `
120
120
0 commit comments