Skip to content

Instantly share code, notes, and snippets.

@edrex
Created February 24, 2016 20:14
Show Gist options
  • Select an option

  • Save edrex/fb947c6fc6460c1629b4 to your computer and use it in GitHub Desktop.

Select an option

Save edrex/fb947c6fc6460c1629b4 to your computer and use it in GitHub Desktop.
::1 - [24/Feb/2016:12:13:53 -0800] "GET / HTTP/1.1" 200 550
::1 - [24/Feb/2016:12:13:53 -0800] "GET /echo HTTP/1.1" 200 0
localhost
log access.log
websocket /echo cat
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
</head>
<body>
<script>
function testEchoSocket(path) {
var s = new WebSocket('ws://'+location.hostname+':'+location.port + path);
s.onmessage = function (event) {
console.log(event.data);
s.close();
}
s.onopen = function (event) {
s.send("ohai");
}
}
testEchoSocket('/echo');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment