From 4514c2c49f0e0ec7cf9911dc254a8d20644d5def Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 5 Aug 2015 21:28:20 -0400 Subject: pushing messages into a div --- public/js/lib/views/room/room.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 public/js/lib/views/room/room.js (limited to 'public/js/lib/views/room/room.js') diff --git a/public/js/lib/views/room/room.js b/public/js/lib/views/room/room.js new file mode 100644 index 0000000..c8d7f3f --- /dev/null +++ b/public/js/lib/views/room/room.js @@ -0,0 +1,29 @@ +var chat + +var RoomView = View.extend({ + + events: { + }, + + initialize: function(name){ + this.name = name + chat = this.chatView = new ChatView () + this.userlist = new UserlistView () + + app.socket = ws.connect(name) + + app.socket.on("joined", function(msgs){ + msgs && msgs.forEach(chat.add) + }) + + app.socket.on("messages", function(msgs){ + msgs && msgs.forEach(chat.add) + }) + + app.socket.on("message", function(msg){ + chat.add(msg) + }) + + } + +}) \ No newline at end of file -- cgit v1.2.3-70-g09d2