summaryrefslogtreecommitdiff
path: root/public/js/lib/views/room/room.js
blob: c8d7f3f5b054f063614bc722456ba61231a0623a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)
    })

  }
  
})