-
Notifications
You must be signed in to change notification settings - Fork 24
/
si-forced.html
53 lines (50 loc) · 1.51 KB
/
si-forced.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!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({
transports: ['websocket']
});
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>