10 this.occupants = {}; |
10 this.occupants = {}; |
11 |
11 |
12 /* Initialize stanza handlers */ |
12 /* Initialize stanza handlers */ |
13 conn.addHandler(recontext(this, this.handle_join), null, "presence", null, null, null); |
13 conn.addHandler(recontext(this, this.handle_join), null, "presence", null, null, null); |
14 conn.addHandler(recontext(this, this.handle_error), null, "presence", "error", null, null); |
14 conn.addHandler(recontext(this, this.handle_error), null, "presence", "error", null, null); |
|
15 conn.addHandler(recontext(this, this.handle_message), null, "message", "groupchat", null, null); |
15 |
16 |
16 /* Return newly-created object */ |
17 /* Return newly-created object */ |
17 return this; |
18 return this; |
18 } |
19 } |
19 |
20 |
94 }); |
95 }); |
95 this.callbacks.error(stanza, this, err); |
96 this.callbacks.error(stanza, this, err); |
96 } |
97 } |
97 } |
98 } |
98 return true; |
99 return true; |
|
100 }, |
|
101 |
|
102 handle_message: function (stanza) |
|
103 { |
|
104 if(!this.callbacks.message) |
|
105 return true; |
|
106 |
|
107 if(stanza.getAttribute("type") == "groupchat" && Strophe.getBareJidFromJid(stanza.getAttribute("from")) == this.jid) |
|
108 { |
|
109 var body = stanza.getElementsByTagName("body"); |
|
110 if(body.length > 0 && stanza.getElementsByTagName("delay").length == 0) |
|
111 this.callbacks.message(stanza, this, Strophe.getResourceFromJid(stanza.getAttribute("from")), Strophe.getText(body[0])); |
|
112 } |
|
113 return true; |
99 } |
114 } |
|
115 |
100 }; |
116 }; |