소스 검색

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,8 +407,11 @@ function initConference(localTracks, connection) {
407 407
     });
408 408
 
409 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 417
     APP.UI.addListener(UIEvents.AUTH_CLICKED, function () {

+ 48
- 12
lib-jitsi-meet.js 파일 보기

@@ -389,12 +389,24 @@ JitsiConference.prototype.getParticipantById = function(id) {
389 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 404
 JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
393 405
     var id = Strophe.getResourceFromJid(jid);
394 406
     if (id === 'focus') {
395 407
        return;
396 408
     }
397
-    var participant = new JitsiParticipant(id, this, nick);
409
+    var participant = new JitsiParticipant(jid, this, nick);
398 410
     this.participants[id] = participant;
399 411
     this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id, participant);
400 412
     this.xmpp.connection.disco.info(
@@ -408,7 +420,7 @@ JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
408 420
 
409 421
 JitsiConference.prototype.onMemberLeft = function (jid) {
410 422
     var id = Strophe.getResourceFromJid(jid);
411
-    if (id === 'focus') {
423
+    if (id === 'focus' || this.myUserId() === id) {
412 424
        return;
413 425
     }
414 426
     var participant = this.participants[id];
@@ -568,6 +580,10 @@ function setupListeners(conference) {
568 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 587
     conference.room.addListener(XMPPEvents.MUC_MEMBER_JOINED, conference.onMemberJoined.bind(conference));
572 588
     conference.room.addListener(XMPPEvents.MUC_MEMBER_LEFT, conference.onMemberLeft.bind(conference));
573 589
 
@@ -765,6 +781,10 @@ var JitsiConferenceEvents = {
765 781
      * Indicates that conference has been left.
766 782
      */
767 783
     CONFERENCE_LEFT: "conference.left",
784
+    /**
785
+     * You are kicked from the conference.
786
+     */
787
+    KICKED: "conferenece.kicked",
768 788
     /**
769 789
      * Indicates that DTMF support changed.
770 790
      */
@@ -1021,11 +1041,14 @@ window.Promise = window.Promise || require("es6-promise").Promise;
1021 1041
 module.exports = LibJitsiMeet;
1022 1042
 
1023 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 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 1052
     this._conference = conference;
1030 1053
     this._displayName = displayName;
1031 1054
     this._supportsDTMF = false;
@@ -1048,12 +1071,19 @@ JitsiParticipant.prototype.getTracks = function() {
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 1076
 JitsiParticipant.prototype.getId = function() {
1054 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 1088
  * @returns {String} The human-readable display name of this participant.
1059 1089
  */
@@ -1093,7 +1123,8 @@ JitsiParticipant.prototype.isVideoMuted = function() {
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 1128
  * TODO: do we expose this or handle it internally?
1098 1129
  */
1099 1130
 JitsiParticipant.prototype.getLatestStats = function() {
@@ -1108,14 +1139,16 @@ JitsiParticipant.prototype.getRole = 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 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 1153
 JitsiParticipant.prototype.isRecorder = function() {
1121 1154
 
@@ -1129,14 +1162,16 @@ JitsiParticipant.prototype.isSipGateway = function() {
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 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 1176
 JitsiParticipant.prototype.getUserAgent = function() {
1142 1177
 
@@ -6240,7 +6275,8 @@ ChatRoom.prototype.onPresenceUnavailable = function (pres, from) {
6240 6275
             reason = reasonSelect.text();
6241 6276
         }
6242 6277
 
6243
-        this.xmpp.disposeConference(false);
6278
+        this.xmpp.leaveRoom(this.roomjid);
6279
+
6244 6280
         this.eventEmitter.emit(XMPPEvents.MUC_DESTROYED, reason);
6245 6281
         delete this.connection.emuc.rooms[Strophe.getBareJidFromJid(from)];
6246 6282
         return true;
@@ -6262,7 +6298,7 @@ ChatRoom.prototype.onPresenceUnavailable = function (pres, from) {
6262 6298
     }
6263 6299
     if ($(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="307"]').length) {
6264 6300
         if (this.myroomjid === from) {
6265
-            this.xmpp.disposeConference(false);
6301
+            this.xmpp.leaveRoom(this.roomjid);
6266 6302
             this.eventEmitter.emit(XMPPEvents.KICKED);
6267 6303
         }
6268 6304
     }

Loading…
취소
저장