with Socket.io
by Alex LaFroscia
emit
on
// Client
// Takes the name of the event and
// the data to be sent as parameters
socket.emit('message', {
sender: 'Alex LaFroscia',
body: 'This is the message'
});
// Server
// Takes the name of the event and a
// callback as parameters
socket.on('message', function(data) {
console.log("Sender: " + data.name);
console.log("Message: " + data.body);
// The message from the client gets
// printed to the server
});
(maybe)