Skip to content

Instantly share code, notes, and snippets.

@youweit
Created August 14, 2013 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save youweit/6228826 to your computer and use it in GitHub Desktop.
Save youweit/6228826 to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<script src='//code.jquery.com/jquery-1.7.2.min.js'></script>
<script src="//localhost:3000/socket.io/socket.io.js" type="text/javascript"></script>
<script>
var socket = io.connect('//localhost:3000');
socket.on('welcome', function(data) {
$('#messages').append('<li>' + data.message + '</li>');
socket.emit('i am client', {data: 'foo!'});
});
socket.on('time', function(data) {
console.log(data);
$('#messages').append('<a>' + data.time + '</a>');
});
socket.on('person', function(data) {
console.log(data);
$('#messages').append('<a>' + data.person +" "+ data.x +" "+data.y +" "+data.z + '</a>');
});
socket.on('error', function() { console.error(arguments) });
socket.on('message', function() { console.log(arguments) });
</script>
</head>
<body>
<a id='messages'></a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment