support-chat/js/xmpp_muc.js

changeset 57
42f5669be677
parent 48
12b42931151a
equal deleted inserted replaced
56:5dd3b23da0ae 57:42f5669be677
23 23
24 this.occupants = {}; 24 this.occupants = {};
25 25
26 /* Initialize stanza handlers */ 26 /* Initialize stanza handlers */
27 conn.addHandler(recontext(this, this.handle_join), null, "presence", null, null, null); 27 conn.addHandler(recontext(this, this.handle_join), null, "presence", null, null, null);
28 conn.addHandler(recontext(this, this.handle_leave), null, "presence", "unavailable", null, null);
28 conn.addHandler(recontext(this, this.handle_error), null, "presence", "error", null, null); 29 conn.addHandler(recontext(this, this.handle_error), null, "presence", "error", null, null);
29 conn.addHandler(recontext(this, this.handle_message), null, "message", "groupchat", null, null); 30 conn.addHandler(recontext(this, this.handle_message), null, "message", "groupchat", null, null);
30 31
31 /* Return newly-created object */ 32 /* Return newly-created object */
32 return this; 33 return this;
106 } 107 }
107 } 108 }
108 return true; 109 return true;
109 }, 110 },
110 111
112 handle_leave: function (stanza)
113 {
114 var nick = Strophe.getResourceFromJid(stanza.getAttribute("from"));
115 if(Strophe.getBareJidFromJid(stanza.getAttribute("from")) == this.jid)
116 if(this.occupants[nick])
117 {
118 var text = stanza.getElementsByTagName("status")[0];
119 if(text)
120 {
121 text = Strophe.getText(text);
122 this.occupants[nick].status = text;
123 }
124 if(this.callbacks.left)
125 this.callbacks.left(stanza, this, this.occupants[nick]);
126 if(this.status_handler)
127 {
128 this.status_handler(stanza);
129 }
130 delete this.occupants[nick];
131 }
132 return true;
133 },
134
111 handle_error: function (stanza) 135 handle_error: function (stanza)
112 { 136 {
113 if(this.callbacks.error 137 if(this.callbacks.error
114 && Strophe.getBareJidFromJid(stanza.getAttribute("from")) == this.jid) 138 && Strophe.getBareJidFromJid(stanza.getAttribute("from")) == this.jid)
115 { 139 {

mercurial