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
var ws = new WebSocket('ws://host.com/path');
ws.on('open', function() {
ws.onopen = () => {
// connection opened
ws.send('something');
});
};
ws.on('message', function(e) {
ws.onmessage = (e) => {
// a message was received
console.log(e.data);
});
};
ws.on('error', function(e) {
ws.onerror = (e) => {
// an error occurred
console.log(e.message);
});
};
ws.on('close', function(e) {
ws.onclose = (e) => {
// connection closed
console.log(e.code, e.reason);
});
};
```
## XMLHttpRequest