|
|
@@ -87,6 +87,7 @@ function ChatRoom(connection, jid, password, XMPP, options, settings) {
|
|
87
|
87
|
this.phoneNumber = null;
|
|
88
|
88
|
this.phonePin = null;
|
|
89
|
89
|
this.connectionTimes = {};
|
|
|
90
|
+ this.participantPropertyListener = null;
|
|
90
|
91
|
}
|
|
91
|
92
|
|
|
92
|
93
|
ChatRoom.prototype.initPresenceMap = function () {
|
|
|
@@ -325,8 +326,8 @@ ChatRoom.prototype.onPresence = function (pres) {
|
|
325
|
326
|
{
|
|
326
|
327
|
case "nick":
|
|
327
|
328
|
if(!member.isFocus) {
|
|
328
|
|
- var displayName = !this.xmpp.options.displayJids
|
|
329
|
|
- ? member.nick : Strophe.getResourceFromJid(from);
|
|
|
329
|
+ var displayName = this.xmpp.options.displayJids
|
|
|
330
|
+ ? Strophe.getResourceFromJid(from) : member.nick;
|
|
330
|
331
|
|
|
331
|
332
|
if (displayName && displayName.length > 0) {
|
|
332
|
333
|
this.eventEmitter.emit(
|
|
|
@@ -351,7 +352,7 @@ ChatRoom.prototype.onPresence = function (pres) {
|
|
351
|
352
|
this.phonePin = att.pin || null;
|
|
352
|
353
|
this.eventEmitter.emit(XMPPEvents.PHONE_NUMBER_CHANGED);
|
|
353
|
354
|
break;
|
|
354
|
|
- default :
|
|
|
355
|
+ default:
|
|
355
|
356
|
this.processNode(node, from);
|
|
356
|
357
|
}
|
|
357
|
358
|
}
|
|
|
@@ -369,13 +370,26 @@ ChatRoom.prototype.onPresence = function (pres) {
|
|
369
|
370
|
}
|
|
370
|
371
|
};
|
|
371
|
372
|
|
|
|
373
|
+/**
|
|
|
374
|
+ * Sets the special listener to be used for "command"s whose name starts with
|
|
|
375
|
+ * "jitsi_participant_".
|
|
|
376
|
+ */
|
|
|
377
|
+ChatRoom.prototype.setParticipantPropertyListener = function (listener) {
|
|
|
378
|
+ this.participantPropertyListener = listener;
|
|
|
379
|
+};
|
|
|
380
|
+
|
|
372
|
381
|
ChatRoom.prototype.processNode = function (node, from) {
|
|
373
|
382
|
// make sure we catch all errors coming from any handler
|
|
374
|
383
|
// otherwise we can remove the presence handler from strophe
|
|
375
|
384
|
try {
|
|
376
|
385
|
var tagHandler = this.presHandlers[node.tagName];
|
|
377
|
|
- if(tagHandler)
|
|
|
386
|
+ if (node.tagName.startsWith("jitsi_participant_")) {
|
|
|
387
|
+ tagHandler = this.participantPropertyListener;
|
|
|
388
|
+ }
|
|
|
389
|
+
|
|
|
390
|
+ if(tagHandler) {
|
|
378
|
391
|
tagHandler(node, Strophe.getResourceFromJid(from), from);
|
|
|
392
|
+ }
|
|
379
|
393
|
} catch (e) {
|
|
380
|
394
|
GlobalOnErrorHandler.callErrorHandler(e);
|
|
381
|
395
|
logger.error('Error processing:' + node.tagName + ' node.', e);
|
|
|
@@ -560,15 +574,14 @@ ChatRoom.prototype.lockRoom = function (key, onSuccess, onError, onNotSupported)
|
|
560
|
574
|
|
|
561
|
575
|
ChatRoom.prototype.addToPresence = function (key, values) {
|
|
562
|
576
|
values.tagName = key;
|
|
563
|
|
- this.presMap["nodes"].push(values);
|
|
|
577
|
+ this.removeFromPresence(key);
|
|
|
578
|
+ this.presMap.nodes.push(values);
|
|
564
|
579
|
};
|
|
565
|
580
|
|
|
566
|
581
|
ChatRoom.prototype.removeFromPresence = function (key) {
|
|
567
|
|
- for(var i = 0; i < this.presMap.nodes.length; i++)
|
|
568
|
|
- {
|
|
569
|
|
- if(key === this.presMap.nodes[i].tagName)
|
|
570
|
|
- this.presMap.nodes.splice(i, 1);
|
|
571
|
|
- }
|
|
|
582
|
+ var nodes = this.presMap.nodes.filter(function(node) {
|
|
|
583
|
+ return key !== node.tagName;});
|
|
|
584
|
+ this.presMap.nodes = nodes;
|
|
572
|
585
|
};
|
|
573
|
586
|
|
|
574
|
587
|
ChatRoom.prototype.addPresenceListener = function (name, handler) {
|