var chat var RoomView = View.extend({ events: { }, initialize: function(name){ app.socket = ws.connect(name) var base = this this.name = name chat = this.chatView = new ChatView (socket) this.userlist = new UserlistView (socket) app.socket.emit("join", { nick: user.username }) app.socket.on("welcome", function(room){ room.messages.forEach(chat.add) base.userlist.users = room.users base.userlist.update() }) app.socket.on("message", function(msg){ chat.add(msg) }) } })