rsp/node-websocket-vs-socket.io

View on GitHub
si.html

Summary

Maintainability
Test Coverage
<!doctype html>
<!--
Socket.IO example - frontend - from:
https://github.com/rsp/node-websocket-vs-socket.io
Copyright (c) 2015, 2016 Rafał Pocztarski
Released under MIT License (Expat) - see:
https://github.com/rsp/node-websocket-vs-socket.io/blob/master/LICENSE.md
-->
<html lang=en>
<head>
<meta charset=utf-8>
<meta name=viewport content="width=device-width, initial-scale=1">
<title>socket.io example - node-websocket-vs-socket.io</title>
<style>
h1 { font-family: helvetica, sans-serif; margin: 0; }
h1+p { margin: 0; }
</style>
</head>
<body>
<h1>socket.io example</h1>
<p>
From node-websocket-vs-socket.io by Rafał Pocztarski
<br><a href="https://github.com/rsp/node-websocket-vs-socket.io">https://github.com/rsp/node-websocket-vs-socket.io</a>
<br>Comparing WebSocket vs. Socket.IO on Node.js with Express.js
</p>
<p>
Open developer tools with Shift+Ctrl+I,
select Network and reload the page.
<br>This is the socket.io example.
See also the <a href="http://localhost:3001/">websocket example</a>.
</p>
<ol id=l></ol>
<script src="/socket.io/socket.io.js"></script>
<script>

var l = document.getElementById('l');
var log = function (m) {
    var i = document.createElement('li');
    i.innerText = new Date().toISOString()+' '+m;
    l.appendChild(i);
}
log('opening socket.io connection');
var s = io();
s.on('connect_error', function (m) { log("error"); });
s.on('connect', function (m) { log("socket.io connection open"); });
s.on('message', function (m) { log(m); });

</script>
</body>
</html>