Browse Source

feat(api): add notifications for kicked participants

master
Leonard Kim 5 years ago
parent
commit
0734ce7ae3

+ 13
- 0
doc/api.md View File

@@ -387,6 +387,19 @@ changes. The listener will receive an object with the following structure:
387 387
 }
388 388
 ```
389 389
 
390
+* **participantKickedOut** - event notifications about a participants being removed from the room. The listener will receive an object with the following structure:
391
+```javascript
392
+{
393
+    kicked: {
394
+        id: string, // the id of the participant removed from the room
395
+        local: boolean // whether or not the participant is the local particiapnt
396
+    },
397
+    kicker: {
398
+        id: string // the id of the participant who kicked out the other participant
399
+    }
400
+}
401
+```
402
+
390 403
 * **participantLeft** - event notifications about participants that leave the room. The listener will receive an object with the following structure:
391 404
 ```javascript
392 405
 {

+ 18
- 0
modules/API/API.js View File

@@ -658,6 +658,24 @@ class API {
658 658
         });
659 659
     }
660 660
 
661
+    /**
662
+     * Notify external application of a participant, remote or local, being
663
+     * removed from the conference by another participant.
664
+     *
665
+     * @param {string} kicked - The ID of the participant removed from the
666
+     * conference.
667
+     * @param {string} kicker - The ID of the participant that removed the
668
+     * other participant.
669
+     * @returns {void}
670
+     */
671
+    notifyKickedOut(kicked: Object, kicker: Object) {
672
+        this._sendEvent({
673
+            name: 'participant-kicked-out',
674
+            kicked,
675
+            kicker
676
+        });
677
+    }
678
+
661 679
     /**
662 680
      * Notify external application of the current meeting requiring a password
663 681
      * to join.

+ 1
- 0
modules/API/external/external_api.js View File

@@ -63,6 +63,7 @@ const events = {
63 63
     'mic-error': 'micError',
64 64
     'outgoing-message': 'outgoingMessage',
65 65
     'participant-joined': 'participantJoined',
66
+    'participant-kicked-out': 'participantKickedOut',
66 67
     'participant-left': 'participantLeft',
67 68
     'password-required': 'passwordRequired',
68 69
     'proxy-connection-event': 'proxyConnectionEvent',

+ 12
- 0
react/features/base/participants/actionTypes.js View File

@@ -65,6 +65,18 @@ export const PARTICIPANT_ID_CHANGED = 'PARTICIPANT_ID_CHANGED';
65 65
  */
66 66
 export const PARTICIPANT_JOINED = 'PARTICIPANT_JOINED';
67 67
 
68
+/**
69
+ * Action to signal that a participant has been removed from a conference by
70
+ * another participant.
71
+ *
72
+ * {
73
+ *     type: PARTICIPANT_KICKED,
74
+ *     kicked: Object,
75
+ *     kicker: Object
76
+ * }
77
+ */
78
+export const PARTICIPANT_KICKED = 'PARTICIPANT_KICKED';
79
+
68 80
 /**
69 81
  * Action to handle case when participant lefts.
70 82
  *

+ 7
- 0
react/features/base/participants/actions.js View File

@@ -9,6 +9,7 @@ import {
9 9
     MUTE_REMOTE_PARTICIPANT,
10 10
     PARTICIPANT_ID_CHANGED,
11 11
     PARTICIPANT_JOINED,
12
+    PARTICIPANT_KICKED,
12 13
     PARTICIPANT_LEFT,
13 14
     PARTICIPANT_UPDATED,
14 15
     PIN_PARTICIPANT
@@ -415,6 +416,12 @@ export function participantMutedUs(participant) {
415 416
 export function participantKicked(kicker, kicked) {
416 417
     return (dispatch, getState) => {
417 418
 
419
+        dispatch({
420
+            type: PARTICIPANT_KICKED,
421
+            kicked: kicked.getId(),
422
+            kicker: kicker.getId()
423
+        });
424
+
418 425
         dispatch(showNotification({
419 426
             titleArguments: {
420 427
                 kicked:

+ 25
- 1
react/features/external-api/middleware.js View File

@@ -1,9 +1,14 @@
1 1
 // @flow
2 2
 
3
-import { CONFERENCE_FAILED, CONFERENCE_JOINED } from '../base/conference';
3
+import {
4
+    CONFERENCE_FAILED,
5
+    CONFERENCE_JOINED,
6
+    KICKED_OUT
7
+} from '../base/conference';
4 8
 import { NOTIFY_CAMERA_ERROR, NOTIFY_MIC_ERROR } from '../base/devices';
5 9
 import { JitsiConferenceErrors } from '../base/lib-jitsi-meet';
6 10
 import {
11
+    PARTICIPANT_KICKED,
7 12
     getAvatarURLByParticipantId,
8 13
     getLocalParticipant
9 14
 } from '../base/participants';
@@ -53,6 +58,16 @@ MiddlewareRegistry.register(store => next => action => {
53 58
         break;
54 59
     }
55 60
 
61
+    case KICKED_OUT:
62
+        APP.API.notifyKickedOut(
63
+            {
64
+                id: getLocalParticipant(store.getState()).id,
65
+                local: true
66
+            },
67
+            { id: action.participant.getId() }
68
+        );
69
+        break;
70
+
56 71
     case NOTIFY_CAMERA_ERROR:
57 72
         if (action.error) {
58 73
             APP.API.notifyOnCameraError(
@@ -66,6 +81,15 @@ MiddlewareRegistry.register(store => next => action => {
66 81
         }
67 82
         break;
68 83
 
84
+    case PARTICIPANT_KICKED:
85
+        APP.API.notifyKickedOut(
86
+            {
87
+                id: action.kicked,
88
+                local: false
89
+            },
90
+            { id: action.kicker });
91
+        break;
92
+
69 93
     case SET_FILMSTRIP_VISIBLE:
70 94
         APP.API.notifyFilmstripDisplayChanged(action.visible);
71 95
         break;

Loading…
Cancel
Save