瀏覽代碼

Catch all errors comming from command handlers to avoid detaching presence handler from strophe connection.

master
damencho 9 年之前
父節點
當前提交
1ddc21e33e
共有 1 個檔案被更改,包括 9 行新增2 行删除
  1. 9
    2
      modules/xmpp/ChatRoom.js

+ 9
- 2
modules/xmpp/ChatRoom.js 查看文件

354
 };
354
 };
355
 
355
 
356
 ChatRoom.prototype.processNode = function (node, from) {
356
 ChatRoom.prototype.processNode = function (node, from) {
357
-    if(this.presHandlers[node.tagName])
358
-        this.presHandlers[node.tagName](
357
+    // make sure we catch all errors coming from any handler
358
+    // otherwise we can remove the presence handler from strophe
359
+    try {
360
+        if(this.presHandlers[node.tagName])
361
+            this.presHandlers[node.tagName](
359
                 node, Strophe.getResourceFromJid(from), from);
362
                 node, Strophe.getResourceFromJid(from), from);
363
+    } catch (e) {
364
+        logger.error('Error processing:' + node.tagName
365
+            + ' node.', e);
366
+    }
360
 };
367
 };
361
 
368
 
362
 ChatRoom.prototype.sendMessage = function (body, nickname) {
369
 ChatRoom.prototype.sendMessage = function (body, nickname) {

Loading…
取消
儲存