Merge pull request #4976 from hosainnet/patch-1

Update incorrect WebSocket example in Network.md
This commit is contained in:
Satyajit Sahoo 2015-12-26 17:12:17 +05:30
commit 65a9e505bd
1 changed files with 8 additions and 8 deletions

View File

@ -74,25 +74,25 @@ WebSocket is a protocol providing full-duplex communication channels over a sing
```js ```js
var ws = new WebSocket('ws://host.com/path'); var ws = new WebSocket('ws://host.com/path');
ws.on('open', function() { ws.onopen = () => {
// connection opened // connection opened
ws.send('something'); ws.send('something');
}); };
ws.on('message', function(e) { ws.onmessage = (e) => {
// a message was received // a message was received
console.log(e.data); console.log(e.data);
}); };
ws.on('error', function(e) { ws.onerror = (e) => {
// an error occurred // an error occurred
console.log(e.message); console.log(e.message);
}); };
ws.on('close', function(e) { ws.onclose = (e) => {
// connection closed // connection closed
console.log(e.code, e.reason); console.log(e.code, e.reason);
}); };
``` ```
## XMLHttpRequest ## XMLHttpRequest