Last active
October 31, 2017 09:39
-
-
Save RaccoonDev/2b694210746656d8771029e67f1d08d1 to your computer and use it in GitHub Desktop.
Websockets testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
'use strict'; | |
var msg = { | |
name: 'channel add', | |
data: { | |
name: 'Hardware support' | |
} | |
}; | |
var ws = new WebSocket('ws://localhost:4000'); | |
ws.onopen = function () { | |
ws.send(JSON.stringify(msg)); | |
}; | |
ws.onmessage = function (e) { | |
console.log(JSON.parse(e.data)); | |
}; | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">let msg = { | |
name: 'channel add', | |
data: { | |
name: 'Hardware support' | |
} | |
} | |
let ws = new WebSocket('ws://localhost:4000'); | |
ws.onopen = () => { | |
ws.send(JSON.stringify(msg)); | |
} | |
ws.onmessage = (e) => { | |
console.log(JSON.parse(e.data)); | |
}</script></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var msg = { | |
name: 'channel add', | |
data: { | |
name: 'Hardware support' | |
} | |
}; | |
var ws = new WebSocket('ws://localhost:4000'); | |
ws.onopen = function () { | |
ws.send(JSON.stringify(msg)); | |
}; | |
ws.onmessage = function (e) { | |
console.log(JSON.parse(e.data)); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment