function User (app) { var base = this; base.name = Math.floor(Math.random() * 1000000) + ""; app.send('event-join', { 'name': base.name }); app.receive('event-join', function(json){ console.log(json); app.chat.receive(json.name, "has joined") }) }