Skip to content

Instantly share code, notes, and snippets.

@youweit youweit/gist:6228826
Created Aug 14, 2013

Embed
What would you like to do?
<!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
You can’t perform that action at this time.