瀏覽代碼

allow to kick users

j8
isymchych 9 年之前
父節點
當前提交
035e20eceb
共有 2 個文件被更改,包括 53 次插入14 次删除
  1. 5
    2
      app.js
  2. 48
    12
      lib-jitsi-meet.js

+ 5
- 2
app.js 查看文件

407
     });
407
     });
408
 
408
 
409
     APP.UI.addListener(UIEvents.USER_KICKED, function (id) {
409
     APP.UI.addListener(UIEvents.USER_KICKED, function (id) {
410
-        // FIXME handle
411
-        // APP.xmpp.eject(self.id);
410
+        room.kickParticipant(id);
411
+    });
412
+    room.on(ConferenceEvents.KICKED, function () {
413
+        APP.UI.notifyKicked();
414
+        // FIXME close
412
     });
415
     });
413
 
416
 
414
     APP.UI.addListener(UIEvents.AUTH_CLICKED, function () {
417
     APP.UI.addListener(UIEvents.AUTH_CLICKED, function () {

+ 48
- 12
lib-jitsi-meet.js 查看文件

389
     return this.participants[id];
389
     return this.participants[id];
390
 };
390
 };
391
 
391
 
392
+/**
393
+ * Kick participant from this conference.
394
+ * @param {string} id id of the participant to kick
395
+ */
396
+JitsiConference.prototype.kickParticipant = function (id) {
397
+    var participant = this.getParticipantById(id);
398
+    if (!participant) {
399
+        return;
400
+    }
401
+    this.room.kick(participant.getJid());
402
+};
403
+
392
 JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
404
 JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
393
     var id = Strophe.getResourceFromJid(jid);
405
     var id = Strophe.getResourceFromJid(jid);
394
     if (id === 'focus') {
406
     if (id === 'focus') {
395
        return;
407
        return;
396
     }
408
     }
397
-    var participant = new JitsiParticipant(id, this, nick);
409
+    var participant = new JitsiParticipant(jid, this, nick);
398
     this.participants[id] = participant;
410
     this.participants[id] = participant;
399
     this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id, participant);
411
     this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id, participant);
400
     this.xmpp.connection.disco.info(
412
     this.xmpp.connection.disco.info(
408
 
420
 
409
 JitsiConference.prototype.onMemberLeft = function (jid) {
421
 JitsiConference.prototype.onMemberLeft = function (jid) {
410
     var id = Strophe.getResourceFromJid(jid);
422
     var id = Strophe.getResourceFromJid(jid);
411
-    if (id === 'focus') {
423
+    if (id === 'focus' || this.myUserId() === id) {
412
        return;
424
        return;
413
     }
425
     }
414
     var participant = this.participants[id];
426
     var participant = this.participants[id];
568
 //        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
580
 //        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
569
 //    });
581
 //    });
570
 
582
 
583
+    conference.room.addListener(XMPPEvents.KICKED, function () {
584
+        conference.eventEmitter.emit(JitsiConferenceEvents.KICKED);
585
+    });
586
+
571
     conference.room.addListener(XMPPEvents.MUC_MEMBER_JOINED, conference.onMemberJoined.bind(conference));
587
     conference.room.addListener(XMPPEvents.MUC_MEMBER_JOINED, conference.onMemberJoined.bind(conference));
572
     conference.room.addListener(XMPPEvents.MUC_MEMBER_LEFT, conference.onMemberLeft.bind(conference));
588
     conference.room.addListener(XMPPEvents.MUC_MEMBER_LEFT, conference.onMemberLeft.bind(conference));
573
 
589
 
765
      * Indicates that conference has been left.
781
      * Indicates that conference has been left.
766
      */
782
      */
767
     CONFERENCE_LEFT: "conference.left",
783
     CONFERENCE_LEFT: "conference.left",
784
+    /**
785
+     * You are kicked from the conference.
786
+     */
787
+    KICKED: "conferenece.kicked",
768
     /**
788
     /**
769
      * Indicates that DTMF support changed.
789
      * Indicates that DTMF support changed.
770
      */
790
      */
1021
 module.exports = LibJitsiMeet;
1041
 module.exports = LibJitsiMeet;
1022
 
1042
 
1023
 },{"./JitsiConferenceErrors":2,"./JitsiConferenceEvents":3,"./JitsiConnection":4,"./JitsiConnectionErrors":5,"./JitsiConnectionEvents":6,"./JitsiTrackErrors":9,"./JitsiTrackEvents":10,"./modules/RTC/RTC":16,"./modules/statistics/statistics":24,"es6-promise":45,"jitsi-meet-logger":47}],8:[function(require,module,exports){
1043
 },{"./JitsiConferenceErrors":2,"./JitsiConferenceEvents":3,"./JitsiConnection":4,"./JitsiConnectionErrors":5,"./JitsiConnectionEvents":6,"./JitsiTrackErrors":9,"./JitsiTrackEvents":10,"./modules/RTC/RTC":16,"./modules/statistics/statistics":24,"es6-promise":45,"jitsi-meet-logger":47}],8:[function(require,module,exports){
1044
+/* global Strophe */
1045
+
1024
 /**
1046
 /**
1025
  * Represents a participant in (a member of) a conference.
1047
  * Represents a participant in (a member of) a conference.
1026
  */
1048
  */
1027
-function JitsiParticipant(id, conference, displayName){
1028
-    this._id = id;
1049
+function JitsiParticipant(jid, conference, displayName){
1050
+    this._jid = jid;
1051
+    this._id = Strophe.getResourceFromJid(jid);
1029
     this._conference = conference;
1052
     this._conference = conference;
1030
     this._displayName = displayName;
1053
     this._displayName = displayName;
1031
     this._supportsDTMF = false;
1054
     this._supportsDTMF = false;
1048
 };
1071
 };
1049
 
1072
 
1050
 /**
1073
 /**
1051
- * @returns {String} The ID (i.e. JID) of this participant.
1074
+ * @returns {String} The ID of this participant.
1052
  */
1075
  */
1053
 JitsiParticipant.prototype.getId = function() {
1076
 JitsiParticipant.prototype.getId = function() {
1054
     return this._id;
1077
     return this._id;
1055
 };
1078
 };
1056
 
1079
 
1080
+/**
1081
+ * @returns {String} The JID of this participant.
1082
+ */
1083
+JitsiParticipant.prototype.getJid = function() {
1084
+    return this._jid;
1085
+};
1086
+
1057
 /**
1087
 /**
1058
  * @returns {String} The human-readable display name of this participant.
1088
  * @returns {String} The human-readable display name of this participant.
1059
  */
1089
  */
1093
 };
1123
 };
1094
 
1124
 
1095
 /*
1125
 /*
1096
- * @returns {???} The latest statistics reported by this participant (i.e. info used to populate the GSM bars)
1126
+ * @returns {???} The latest statistics reported by this participant
1127
+ * (i.e. info used to populate the GSM bars)
1097
  * TODO: do we expose this or handle it internally?
1128
  * TODO: do we expose this or handle it internally?
1098
  */
1129
  */
1099
 JitsiParticipant.prototype.getLatestStats = function() {
1130
 JitsiParticipant.prototype.getLatestStats = function() {
1108
 };
1139
 };
1109
 
1140
 
1110
 /*
1141
 /*
1111
- * @returns {Boolean} Whether this participant is the conference focus (i.e. jicofo).
1142
+ * @returns {Boolean} Whether this participant is
1143
+ * the conference focus (i.e. jicofo).
1112
  */
1144
  */
1113
 JitsiParticipant.prototype.isFocus = function() {
1145
 JitsiParticipant.prototype.isFocus = function() {
1114
 
1146
 
1115
 };
1147
 };
1116
 
1148
 
1117
 /*
1149
 /*
1118
- * @returns {Boolean} Whether this participant is a conference recorder (i.e. jirecon).
1150
+ * @returns {Boolean} Whether this participant is
1151
+ * a conference recorder (i.e. jirecon).
1119
  */
1152
  */
1120
 JitsiParticipant.prototype.isRecorder = function() {
1153
 JitsiParticipant.prototype.isRecorder = function() {
1121
 
1154
 
1129
 };
1162
 };
1130
 
1163
 
1131
 /**
1164
 /**
1132
- * @returns {Boolean} Whether this participant is currently sharing their screen.
1165
+ * @returns {Boolean} Whether this participant
1166
+ * is currently sharing their screen.
1133
  */
1167
  */
1134
 JitsiParticipant.prototype.isScreenSharing = function() {
1168
 JitsiParticipant.prototype.isScreenSharing = function() {
1135
 
1169
 
1136
 };
1170
 };
1137
 
1171
 
1138
 /**
1172
 /**
1139
- * @returns {String} The user agent of this participant (i.e. browser userAgent string).
1173
+ * @returns {String} The user agent of this participant
1174
+ * (i.e. browser userAgent string).
1140
  */
1175
  */
1141
 JitsiParticipant.prototype.getUserAgent = function() {
1176
 JitsiParticipant.prototype.getUserAgent = function() {
1142
 
1177
 
6240
             reason = reasonSelect.text();
6275
             reason = reasonSelect.text();
6241
         }
6276
         }
6242
 
6277
 
6243
-        this.xmpp.disposeConference(false);
6278
+        this.xmpp.leaveRoom(this.roomjid);
6279
+
6244
         this.eventEmitter.emit(XMPPEvents.MUC_DESTROYED, reason);
6280
         this.eventEmitter.emit(XMPPEvents.MUC_DESTROYED, reason);
6245
         delete this.connection.emuc.rooms[Strophe.getBareJidFromJid(from)];
6281
         delete this.connection.emuc.rooms[Strophe.getBareJidFromJid(from)];
6246
         return true;
6282
         return true;
6262
     }
6298
     }
6263
     if ($(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="307"]').length) {
6299
     if ($(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="307"]').length) {
6264
         if (this.myroomjid === from) {
6300
         if (this.myroomjid === from) {
6265
-            this.xmpp.disposeConference(false);
6301
+            this.xmpp.leaveRoom(this.roomjid);
6266
             this.eventEmitter.emit(XMPPEvents.KICKED);
6302
             this.eventEmitter.emit(XMPPEvents.KICKED);
6267
         }
6303
         }
6268
     }
6304
     }

Loading…
取消
儲存