Adds setting subject and adding event on receiving such change.

This commit is contained in:
damencho 2019-02-17 14:40:24 +00:00 committed by Дамян Минков
parent 54c36198d0
commit fc129d9849
7 changed files with 102 additions and 2 deletions

View File

@ -45,7 +45,8 @@ import {
onStartMutedPolicyChanged,
p2pStatusChanged,
sendLocalParticipant,
setDesktopSharingEnabled
setDesktopSharingEnabled,
setSubject
} from './react/features/base/conference';
import {
getAvailableDevices,
@ -1825,6 +1826,8 @@ export default {
room.on(JitsiConferenceEvents.TALK_WHILE_MUTED, () => {
APP.UI.showToolbar(6000);
});
room.on(JitsiConferenceEvents.SUBJECT_CHANGED,
subject => APP.API.notifySubjectChanged(subject));
room.on(
JitsiConferenceEvents.LAST_N_ENDPOINTS_CHANGED,
@ -2756,6 +2759,16 @@ export default {
APP.API.notifyAudioMutedStatusChanged(muted);
},
/**
* Changes the subject of the conference.
* Note: available only for moderator.
*
* @param subject {string} the new subject for the conference.
*/
setSubject(subject) {
APP.store.dispatch(setSubject(subject));
},
/**
* Dispatches the passed in feedback for submission. The submitted score
* should be a number inclusively between 1 through 5, or -1 for no score.

View File

@ -78,6 +78,11 @@ The `command` parameter is String object with the name of the command. The follo
api.executeCommand('displayName', 'New Nickname');
```
* **subject** - Sets the subject of the conference. This command requires one argument - the new subject to be set.
```javascript
api.executeCommand('subject', 'New Conference Subject');
```
* **toggleAudio** - Mutes / unmutes the audio for the local participant. No arguments are required.
```javascript
api.executeCommand('toggleAudio')
@ -251,6 +256,14 @@ changes. The listener will receive an object with the following structure:
* **readyToClose** - event notification fired when Jitsi Meet is ready to be closed (hangup operations are completed).
* **subjectChange** - event notifications about subject of conference changes.
The listener will receive an object with the following structure:
```javascript
{
"subject": subject // the new subject
}
```
You can also add multiple event listeners by using `addEventListeners`.
This method requires one argument of type Object. The object argument must
have the names of the events as keys and the listeners of the events as values.

View File

@ -63,6 +63,10 @@ function initCommands() {
'proxy-connection-event': event => {
APP.conference.onProxyConnectionEvent(event);
},
'subject': subject => {
sendAnalytics(createApiEvent('subject.changed'));
APP.conference.setSubject(subject);
},
'submit-feedback': feedback => {
sendAnalytics(createApiEvent('submit.feedback'));
APP.conference.submitFeedback(feedback.score, feedback.message);
@ -551,6 +555,20 @@ class API {
});
}
/**
* Notify external application (if API is enabled) that the conference
* changed their subject.
*
* @param {string} subject - Conference subject.
* @returns {void}
*/
notifySubjectChanged(subject: string) {
this._sendEvent({
name: 'subject-change',
subject
});
}
/**
* Disposes the allocated resources.
*

View File

@ -23,6 +23,7 @@ const commands = {
displayName: 'display-name',
email: 'email',
hangup: 'video-hangup',
subject: 'subject',
submitFeedback: 'submit-feedback',
toggleAudio: 'toggle-audio',
toggleChat: 'toggle-chat',
@ -52,7 +53,8 @@ const events = {
'video-conference-left': 'videoConferenceLeft',
'video-availability-changed': 'videoAvailabilityChanged',
'video-mute-status-changed': 'videoMuteStatusChanged',
'screen-sharing-status-changed': 'screenSharingStatusChanged'
'screen-sharing-status-changed': 'screenSharingStatusChanged',
'subject-change': 'subjectChange'
};
/**
@ -542,6 +544,9 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
* Executes command. The available commands are:
* {@code displayName} - Sets the display name of the local participant to
* the value passed in the arguments array.
* {@code subject} - Sets the subject of the conference, the value passed
* in the arguments array. Note: available only for moderator.
*
* {@code toggleAudio} - Mutes / unmutes audio with no arguments.
* {@code toggleVideo} - Mutes / unmutes video with no arguments.
* {@code toggleFilmStrip} - Hides / shows the filmstrip with no arguments.

View File

@ -119,6 +119,16 @@ export const P2P_STATUS_CHANGED = Symbol('P2P_STATUS_CHANGED');
*/
export const SET_AUDIO_ONLY = Symbol('SET_AUDIO_ONLY');
/**
* The type of (redux) action, which indicates to set conference subject.
*
* {
* type: SET_CONFERENCE_SUBJECT
* subject: string
* }
*/
export const SET_CONFERENCE_SUBJECT = Symbol('SET_CONFERENCE_SUBJECT');
/**
* The type of (redux) action which sets the desktop sharing enabled flag for
* the current conference.

View File

@ -33,6 +33,7 @@ import {
LOCK_STATE_CHANGED,
P2P_STATUS_CHANGED,
SET_AUDIO_ONLY,
SET_CONFERENCE_SUBJECT,
SET_DESKTOP_SHARING_ENABLED,
SET_FOLLOW_ME,
SET_LASTN,
@ -728,3 +729,16 @@ export function toggleAudioOnly() {
return dispatch(setAudioOnly(!audioOnly, true));
};
}
/**
* Changing conference subject.
*
* @param {string} subject - The new subject.
* @returns {void}
*/
export function setSubject(subject: String) {
return {
type: SET_CONFERENCE_SUBJECT,
subject
};
}

View File

@ -35,6 +35,7 @@ import {
CONFERENCE_WILL_LEAVE,
DATA_CHANNEL_OPENED,
SET_AUDIO_ONLY,
SET_CONFERENCE_SUBJECT,
SET_LASTN,
SET_ROOM
} from './actionTypes';
@ -90,6 +91,9 @@ MiddlewareRegistry.register(store => next => action => {
case SET_AUDIO_ONLY:
return _setAudioOnly(store, next, action);
case SET_CONFERENCE_SUBJECT:
return _setSubject(store, next, action);
case SET_LASTN:
return _setLastN(store, next, action);
@ -679,3 +683,26 @@ function _updateLocalParticipantInConference({ getState }, next, action) {
return result;
}
/**
* Changing conference subject.
*
* @param {Store} store - The redux store in which the specified {@code action}
* is being dispatched.
* @param {Dispatch} next - The redux {@code dispatch} function to dispatch the
* specified {@code action} to the specified {@code store}.
* @param {Action} action - The redux action which is being dispatched in the
* specified {@code store}.
* @private
* @returns {Object} The value returned by {@code next(action)}.
*/
function _setSubject({ getState }, next, action) {
const { conference } = getState()['features/base/conference'];
const { subject } = action;
if (subject) {
conference.setSubject(subject);
}
return next(action);
}