ソースを参照

add "kick participant" support

tags/v0.0.2
isymchych 9年前
コミット
8f94abff1b
6個のファイルの変更100行の追加24行の削除
  1. 18
    2
      JitsiConference.js
  2. 4
    0
      JitsiConferenceEvents.js
  3. 23
    8
      JitsiParticipant.js
  4. 4
    0
      doc/API.md
  5. 48
    12
      lib-jitsi-meet.js
  6. 3
    2
      modules/xmpp/ChatRoom.js

+ 18
- 2
JitsiConference.js ファイルの表示

387
     return this.participants[id];
387
     return this.participants[id];
388
 };
388
 };
389
 
389
 
390
+/**
391
+ * Kick participant from this conference.
392
+ * @param {string} id id of the participant to kick
393
+ */
394
+JitsiConference.prototype.kickParticipant = function (id) {
395
+    var participant = this.getParticipantById(id);
396
+    if (!participant) {
397
+        return;
398
+    }
399
+    this.room.kick(participant.getJid());
400
+};
401
+
390
 JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
402
 JitsiConference.prototype.onMemberJoined = function (jid, email, nick) {
391
     var id = Strophe.getResourceFromJid(jid);
403
     var id = Strophe.getResourceFromJid(jid);
392
     if (id === 'focus') {
404
     if (id === 'focus') {
393
        return;
405
        return;
394
     }
406
     }
395
-    var participant = new JitsiParticipant(id, this, nick);
407
+    var participant = new JitsiParticipant(jid, this, nick);
396
     this.participants[id] = participant;
408
     this.participants[id] = participant;
397
     this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id, participant);
409
     this.eventEmitter.emit(JitsiConferenceEvents.USER_JOINED, id, participant);
398
     this.xmpp.connection.disco.info(
410
     this.xmpp.connection.disco.info(
406
 
418
 
407
 JitsiConference.prototype.onMemberLeft = function (jid) {
419
 JitsiConference.prototype.onMemberLeft = function (jid) {
408
     var id = Strophe.getResourceFromJid(jid);
420
     var id = Strophe.getResourceFromJid(jid);
409
-    if (id === 'focus') {
421
+    if (id === 'focus' || this.myUserId() === id) {
410
        return;
422
        return;
411
     }
423
     }
412
     var participant = this.participants[id];
424
     var participant = this.participants[id];
566
 //        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
578
 //        conference.eventEmitter.emit(JitsiConferenceEvents.CONFERENCE_LEFT);
567
 //    });
579
 //    });
568
 
580
 
581
+    conference.room.addListener(XMPPEvents.KICKED, function () {
582
+        conference.eventEmitter.emit(JitsiConferenceEvents.KICKED);
583
+    });
584
+
569
     conference.room.addListener(XMPPEvents.MUC_MEMBER_JOINED, conference.onMemberJoined.bind(conference));
585
     conference.room.addListener(XMPPEvents.MUC_MEMBER_JOINED, conference.onMemberJoined.bind(conference));
570
     conference.room.addListener(XMPPEvents.MUC_MEMBER_LEFT, conference.onMemberLeft.bind(conference));
586
     conference.room.addListener(XMPPEvents.MUC_MEMBER_LEFT, conference.onMemberLeft.bind(conference));
571
 
587
 

+ 4
- 0
JitsiConferenceEvents.js ファイルの表示

80
      * Indicates that conference has been left.
80
      * Indicates that conference has been left.
81
      */
81
      */
82
     CONFERENCE_LEFT: "conference.left",
82
     CONFERENCE_LEFT: "conference.left",
83
+    /**
84
+     * You are kicked from the conference.
85
+     */
86
+    KICKED: "conferenece.kicked",
83
     /**
87
     /**
84
      * Indicates that DTMF support changed.
88
      * Indicates that DTMF support changed.
85
      */
89
      */

+ 23
- 8
JitsiParticipant.js ファイルの表示

1
+/* global Strophe */
2
+
1
 /**
3
 /**
2
  * Represents a participant in (a member of) a conference.
4
  * Represents a participant in (a member of) a conference.
3
  */
5
  */
4
-function JitsiParticipant(id, conference, displayName){
5
-    this._id = id;
6
+function JitsiParticipant(jid, conference, displayName){
7
+    this._jid = jid;
8
+    this._id = Strophe.getResourceFromJid(jid);
6
     this._conference = conference;
9
     this._conference = conference;
7
     this._displayName = displayName;
10
     this._displayName = displayName;
8
     this._supportsDTMF = false;
11
     this._supportsDTMF = false;
25
 };
28
 };
26
 
29
 
27
 /**
30
 /**
28
- * @returns {String} The ID (i.e. JID) of this participant.
31
+ * @returns {String} The ID of this participant.
29
  */
32
  */
30
 JitsiParticipant.prototype.getId = function() {
33
 JitsiParticipant.prototype.getId = function() {
31
     return this._id;
34
     return this._id;
32
 };
35
 };
33
 
36
 
37
+/**
38
+ * @returns {String} The JID of this participant.
39
+ */
40
+JitsiParticipant.prototype.getJid = function() {
41
+    return this._jid;
42
+};
43
+
34
 /**
44
 /**
35
  * @returns {String} The human-readable display name of this participant.
45
  * @returns {String} The human-readable display name of this participant.
36
  */
46
  */
70
 };
80
 };
71
 
81
 
72
 /*
82
 /*
73
- * @returns {???} The latest statistics reported by this participant (i.e. info used to populate the GSM bars)
83
+ * @returns {???} The latest statistics reported by this participant
84
+ * (i.e. info used to populate the GSM bars)
74
  * TODO: do we expose this or handle it internally?
85
  * TODO: do we expose this or handle it internally?
75
  */
86
  */
76
 JitsiParticipant.prototype.getLatestStats = function() {
87
 JitsiParticipant.prototype.getLatestStats = function() {
85
 };
96
 };
86
 
97
 
87
 /*
98
 /*
88
- * @returns {Boolean} Whether this participant is the conference focus (i.e. jicofo).
99
+ * @returns {Boolean} Whether this participant is
100
+ * the conference focus (i.e. jicofo).
89
  */
101
  */
90
 JitsiParticipant.prototype.isFocus = function() {
102
 JitsiParticipant.prototype.isFocus = function() {
91
 
103
 
92
 };
104
 };
93
 
105
 
94
 /*
106
 /*
95
- * @returns {Boolean} Whether this participant is a conference recorder (i.e. jirecon).
107
+ * @returns {Boolean} Whether this participant is
108
+ * a conference recorder (i.e. jirecon).
96
  */
109
  */
97
 JitsiParticipant.prototype.isRecorder = function() {
110
 JitsiParticipant.prototype.isRecorder = function() {
98
 
111
 
106
 };
119
 };
107
 
120
 
108
 /**
121
 /**
109
- * @returns {Boolean} Whether this participant is currently sharing their screen.
122
+ * @returns {Boolean} Whether this participant
123
+ * is currently sharing their screen.
110
  */
124
  */
111
 JitsiParticipant.prototype.isScreenSharing = function() {
125
 JitsiParticipant.prototype.isScreenSharing = function() {
112
 
126
 
113
 };
127
 };
114
 
128
 
115
 /**
129
 /**
116
- * @returns {String} The user agent of this participant (i.e. browser userAgent string).
130
+ * @returns {String} The user agent of this participant
131
+ * (i.e. browser userAgent string).
117
  */
132
  */
118
 JitsiParticipant.prototype.getUserAgent = function() {
133
 JitsiParticipant.prototype.getUserAgent = function() {
119
 
134
 

+ 4
- 0
doc/API.md ファイルの表示

80
         - DTMF_SUPPORT_CHANGED - notifies if at least one user supports DTMF. (parameters - supports(boolean))
80
         - DTMF_SUPPORT_CHANGED - notifies if at least one user supports DTMF. (parameters - supports(boolean))
81
         - USER_ROLE_CHANGED - notifies that role of some user changed. (parameters - id(string), role(string))
81
         - USER_ROLE_CHANGED - notifies that role of some user changed. (parameters - id(string), role(string))
82
         - CONFERENCE_FAILED - notifies that user failed to join the conference. (parameters - errorCode(JitsiMeetJS.errors.conference))
82
         - CONFERENCE_FAILED - notifies that user failed to join the conference. (parameters - errorCode(JitsiMeetJS.errors.conference))
83
+        - KICKED - notifies that user has been kicked from the conference.
83
 
84
 
84
     2. connection
85
     2. connection
85
         - CONNECTION_FAILED - indicates that the server connection failed.
86
         - CONNECTION_FAILED - indicates that the server connection failed.
238
 
239
 
239
     Note: available only for moderator
240
     Note: available only for moderator
240
 
241
 
242
+24. kick(id) - Kick participant from the conference
243
+    - id - string participant id
244
+
241
 JitsiTrack
245
 JitsiTrack
242
 ======
246
 ======
243
 The object represents single track - video or audio. They can be remote tracks ( from the other participants in the call) or local tracks (from the devices of the local participant).
247
 The object represents single track - video or audio. They can be remote tracks ( from the other participants in the call) or local tracks (from the devices of the local participant).

+ 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
     }

+ 3
- 2
modules/xmpp/ChatRoom.js ファイルの表示

374
             reason = reasonSelect.text();
374
             reason = reasonSelect.text();
375
         }
375
         }
376
 
376
 
377
-        this.xmpp.disposeConference(false);
377
+        this.xmpp.leaveRoom(this.roomjid);
378
+
378
         this.eventEmitter.emit(XMPPEvents.MUC_DESTROYED, reason);
379
         this.eventEmitter.emit(XMPPEvents.MUC_DESTROYED, reason);
379
         delete this.connection.emuc.rooms[Strophe.getBareJidFromJid(from)];
380
         delete this.connection.emuc.rooms[Strophe.getBareJidFromJid(from)];
380
         return true;
381
         return true;
396
     }
397
     }
397
     if ($(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="307"]').length) {
398
     if ($(pres).find('>x[xmlns="http://jabber.org/protocol/muc#user"]>status[code="307"]').length) {
398
         if (this.myroomjid === from) {
399
         if (this.myroomjid === from) {
399
-            this.xmpp.disposeConference(false);
400
+            this.xmpp.leaveRoom(this.roomjid);
400
             this.eventEmitter.emit(XMPPEvents.KICKED);
401
             this.eventEmitter.emit(XMPPEvents.KICKED);
401
         }
402
         }
402
     }
403
     }

読み込み中…
キャンセル
保存