Explorar el Código

Fires CONFERENCE_LEFT event once we receive our presence unavailable.

dev1
damencho hace 9 años
padre
commit
cbf2eebeec
Se han modificado 4 ficheros con 28 adiciones y 12 borrados
  1. 4
    3
      JitsiConference.js
  2. 2
    0
      JitsiConferenceEventManager.js
  3. 20
    9
      modules/xmpp/ChatRoom.js
  4. 2
    0
      service/xmpp/XMPPEvents.js

+ 4
- 3
JitsiConference.js Ver fichero

@@ -147,8 +147,6 @@ JitsiConference.prototype._leaveRoomAndRemoveParticipants = function () {
147 147
     }
148 148
 
149 149
     this.room = null;
150
-
151
-    this.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
152 150
 }
153 151
 /**
154 152
  * Leaves the conference.
@@ -721,7 +719,10 @@ JitsiConference.prototype.onMemberLeft = function (jid) {
721 719
         this.eventEmitter.emit(JitsiConferenceEvents.TRACK_REMOVED, track);
722 720
     }.bind(this));
723 721
 
724
-    this.eventEmitter.emit(JitsiConferenceEvents.USER_LEFT, id, participant);
722
+    // there can be no participant in case the member that left is focus
723
+    if (participant)
724
+        this.eventEmitter.emit(
725
+            JitsiConferenceEvents.USER_LEFT, id, participant);
725 726
 };
726 727
 
727 728
 JitsiConference.prototype.onUserRoleChanged = function (jid, role) {

+ 2
- 0
JitsiConferenceEventManager.js Ver fichero

@@ -236,6 +236,8 @@ JitsiConferenceEventManager.prototype.setupChatRoomListeners = function () {
236 236
         conference.onMemberJoined.bind(conference));
237 237
     chatRoom.addListener(XMPPEvents.MUC_MEMBER_LEFT,
238 238
         conference.onMemberLeft.bind(conference));
239
+    this.chatRoomForwarder.forward(XMPPEvents.MUC_LEFT,
240
+        JitsiConferenceEvents.CONFERENCE_LEFT);
239 241
 
240 242
     chatRoom.addListener(XMPPEvents.DISPLAY_NAME_CHANGED,
241 243
         conference.onDisplayNameChanged.bind(conference));

+ 20
- 9
modules/xmpp/ChatRoom.js Ver fichero

@@ -173,7 +173,10 @@ ChatRoom.prototype.sendPresence = function (fromJoin) {
173 173
     }
174 174
 };
175 175
 
176
-
176
+/**
177
+ * Sends the presence unavailable, signaling the server
178
+ * we want to leave the room.
179
+ */
177 180
 ChatRoom.prototype.doLeave = function () {
178 181
     logger.log("do leave", this.myroomjid);
179 182
     var pres = $pres({to: this.myroomjid, type: 'unavailable' });
@@ -490,10 +493,10 @@ ChatRoom.prototype.onPresenceUnavailable = function (pres, from) {
490 493
             reason = reasonSelect.text();
491 494
         }
492 495
 
493
-        this.leave();
496
+        this._dispose();
494 497
 
495 498
         this.eventEmitter.emit(XMPPEvents.MUC_DESTROYED, reason);
496
-        delete this.connection.emuc.rooms[Strophe.getBareJidFromJid(from)];
499
+        this.connection.emuc.doLeave(this.roomjid);
497 500
         return true;
498 501
     }
499 502
 
@@ -510,10 +513,14 @@ ChatRoom.prototype.onPresenceUnavailable = function (pres, from) {
510 513
             delete this.members[i];
511 514
             this.onParticipantLeft(i, member.isFocus);
512 515
         }
516
+        this.connection.emuc.doLeave(this.roomjid);
517
+        this.eventEmitter.emit(XMPPEvents.MUC_LEFT);
513 518
     }
519
+
514 520
     if ($(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="307"]').length) {
515 521
         if (this.myroomjid === from) {
516
-            this.leave(true);
522
+            this._dispose();
523
+            this.connection.emuc.doLeave(this.roomjid);
517 524
             this.eventEmitter.emit(XMPPEvents.KICKED);
518 525
         }
519 526
     }
@@ -946,16 +953,20 @@ ChatRoom.prototype.onMute = function (iq) {
946 953
 
947 954
 /**
948 955
  * Leaves the room. Closes the jingle session.
949
- * @parama voidSendingPresence avoids sending the presence when leaving
950 956
  */
951
-ChatRoom.prototype.leave = function (avoidSendingPresence) {
957
+ChatRoom.prototype.leave = function () {
958
+    this._dispose();
959
+    this.doLeave();
960
+};
961
+
962
+/**
963
+ * Disposes the conference, closes the jingle session.
964
+ */
965
+ChatRoom.prototype._dispose = function () {
952 966
     if (this.session) {
953 967
         this.session.close();
954 968
     }
955 969
     this.eventEmitter.emit(XMPPEvents.DISPOSE_CONFERENCE);
956
-    if(!avoidSendingPresence)
957
-        this.doLeave();
958
-    this.connection.emuc.doLeave(this.roomjid);
959 970
 };
960 971
 
961 972
 module.exports = ChatRoom;

+ 2
- 0
service/xmpp/XMPPEvents.js Ver fichero

@@ -81,6 +81,8 @@ var XMPPEvents = {
81 81
     MUC_MEMBER_JOINED: "xmpp.muc_member_joined",
82 82
     // Designates an event indicating that a participant left the XMPP MUC.
83 83
     MUC_MEMBER_LEFT: "xmpp.muc_member_left",
84
+    // Designates an event indicating that local participant left the muc
85
+    MUC_LEFT: "xmpp.muc_left",
84 86
     // Designates an event indicating that the MUC role of a participant has
85 87
     // changed.
86 88
     MUC_ROLE_CHANGED: "xmpp.muc_role_changed",

Loading…
Cancelar
Guardar