Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

56 lines (52 sloc) 1.593 kB
<!DOCTYPE html>
<html lang='en'>
<head>
<title>Socket.io test</title>
<style>
#output {
border: 1px solid #ddd;
min-height: 300px;
}
</style>
<script src="http://www.google.com/jsapi"></script>
<script>
google.load("jquery", '1');
</script>
</head>
<body>
<h1>Hello other world!</h1>
<div id="output">
<pre>
still empty...
</pre>
</div>
<input type="text" name="message" />
<script src="socket.io/socket.io.js"></script>
<!-- <script src="http://localhost:3000/socket.io/socket.io.js"></script> -->
<!-- <script src="http://node-tracker.herokuapp.com/socket.io/socket.io.js"></script> -->
<script>
$(function() {
window.socket = new io.Socket(document.location.hostname, {port: document.location.port});
// window.socket = new io.Socket('http://node-tracker.herokuapp.com', {port: 80});
socket.connect();
socket.on('connect', function() {
console.log('connect');
})
socket.on('message', function(msg) {
console.log('message:', msg.message.message);
$('pre').append( $('<strong>[' + msg.message.session_id + ']</strong> <span>' + msg.message.message + "</span>")).append("\n\r").scrollTo();
})
socket.on('disconnect', function() {
console.log('disconnect');
})
$('input[name=message]').keypress('keypress', function(event) {
if (event.which == 13) {
var $this = $(this);
window.socket.send( $this.val() );
$this.val('');
}
});
});
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.