-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added socket.io forced websockets feature
- Loading branch information
1 parent
f61733a
commit 70cf186
Showing
4 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!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> | ||
|
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
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