Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dirty hack so essen doesn't need node.
- Loading branch information
Simon MacMullen
committed
Oct 3, 2011
1 parent
95b8c7a
commit 8f2c7a0
Showing
16 changed files
with
3,164 additions
and
2 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,16 @@ | ||
exports.config = { | ||
opts: { | ||
sockjs_url: "/lib/sockjs.js" | ||
}, | ||
port: process.env.PORT || 8080, | ||
host: '0.0.0.0', | ||
|
||
client_opts: { | ||
// May be set to empty string if you don't need to test | ||
// cross-domain features. In other case set it to a full | ||
// url, like: "http://localhost:8080" | ||
disabled_transports: [], | ||
url: '', | ||
sockjs_opts: {devel:true} | ||
} | ||
}; |
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,118 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta charset="UTF-8" /> | ||
|
||
<link href="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII=" rel="icon" type="image/x-icon" /> | ||
|
||
<script type="text/javascript" src="lib/sockjs.js"></script> | ||
<script type="text/javascript" src="static/jquery.min.js"></script> | ||
|
||
<script type="text/javascript" src="config.js"></script> | ||
|
||
<style type="text/css"> | ||
.cursor { | ||
height: 30px; | ||
width: 30px; | ||
position: absolute; | ||
border: 1px solid grey; | ||
z-index:-1; | ||
} | ||
|
||
</style> | ||
|
||
</head> | ||
<body> | ||
|
||
<form> | ||
<select id="transport"> | ||
<option value="">- any - </option> | ||
<option value="websocket">websocket</option> | ||
<option value="xhr-streaming">xhr-streaming</option> | ||
<option value="iframe-eventsource">iframe-eventsource</option> | ||
<option value="iframe-htmlfile">iframe-htmlfile</option> | ||
<option value="xhr-polling">xhr-polling</option> | ||
<option value="iframe-xhr-polling">iframe-xhr-polling</option> | ||
<option value="jsonp-polling">jsonp-polling</option> | ||
</select> | ||
<input type="button" value="Connect" id="connect"> | ||
<input type="button" value="Disconnect" id="disconnect" disabled="yes"> | ||
</form> | ||
|
||
Latency: <code id="latency"></code><br> | ||
<code id="logs" style="height:200px; overflow:auto; display: block; border: 1px grey solid;"> | ||
</code> | ||
|
||
<script> | ||
function log(a) { | ||
if ('console' in window && 'log' in window.console) { | ||
console.log(a); | ||
} | ||
$('#logs').append($("<code>").text(a)); | ||
$('#logs').append($("<br>")); | ||
$('#logs').scrollTop($('#logs').scrollTop()+10000); | ||
} | ||
|
||
var sjs = null; | ||
var protocol; | ||
$('#connect').click(function() { | ||
$('#connect').attr('disabled', true); | ||
$('#disconnect').attr('disabled', false); | ||
var protocol = $('#transport').val() || undefined; | ||
log('[connecting] ' + protocol); | ||
sjs = new SockJS(client_opts.url + '/broadcast', protocol, client_opts.sockjs_opts); | ||
sjs.onopen = onopen | ||
sjs.onclose = onclose; | ||
sjs.onmessage = onmessage; | ||
}); | ||
$('#disconnect').click(function() { | ||
$('#disconnect').attr('disabled', true); | ||
log('[disconnecting]'); | ||
sjs.close(); | ||
}); | ||
|
||
var onopen = function() { | ||
log('connected ' + sjs.protocol); | ||
}; | ||
var onclose = function(e) { | ||
log('disconnected ' + e); | ||
$('#connect').attr('disabled', false); | ||
$('#disconnect').attr('disabled', true); | ||
}; | ||
var myself = (''+Math.random()).substr(2); | ||
var onmessage = function(e) { | ||
var msg = JSON.parse(e.data); | ||
if (msg.id === myself) { | ||
var td = (new Date()).getTime() - msg.t; | ||
$('#latency').text('' + td + ' ms'); | ||
} | ||
var id = 'cursor_'+msg.id; | ||
if ($('#'+id).length === 0) { | ||
$("body").append('<div id="' + id + '" class="cursor"></div>'); | ||
} | ||
$('#'+id).offset({top:msg.y-15, left:msg.x-15}); | ||
}; | ||
var x, y; | ||
var last_x, last_y, tref; | ||
$(document).mousemove(function(e) { | ||
x = e.pageX; y = e.pageY; | ||
if(!tref) poll(); | ||
}); | ||
var poll = function() { | ||
tref = null; | ||
if (last_x === x && last_y === y) | ||
return; | ||
var msg = {x:x, y:y, t: (new Date()).getTime(), id:myself}; | ||
last_x = x; last_y = y; | ||
var raw_msg = JSON.stringify(msg); | ||
if (sjs && sjs.readyState === SockJS.OPEN) { | ||
sjs.send(raw_msg); | ||
} | ||
tref = setTimeout(poll, 200); | ||
}; | ||
$('#connect').attr('disabled', false); | ||
$('#disconnect').attr('disabled', true); | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta charset="UTF-8" /> | ||
|
||
<link href="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQEAYAAABPYyMiAAAABmJLR0T///////8JWPfcAAAACXBIWXMAAABIAAAASABGyWs+AAAAF0lEQVRIx2NgGAWjYBSMglEwCkbBSAcACBAAAeaR9cIAAAAASUVORK5CYII=" rel="icon" type="image/x-icon" /> | ||
|
||
</head> | ||
<body> | ||
<h1>SockJS</h1> | ||
<ul> | ||
<li><a href="tests-qunit.html">QUnit tests</a></li> | ||
<li><a href="example-cursors.html">Cursors example</a></li> | ||
<li><a href="smoke-throughput.html">Smoketest: througput</a></li> | ||
<li><a href="smoke-reconnect.html">Smoketest: reconnect</a></li> | ||
</ul> | ||
</body> | ||
</html> |
Empty file.
Oops, something went wrong.