ref(remotecontrol): To use transport module instead of API
This commit is contained in:
parent
0dff35c0db
commit
54388b6a0a
|
@ -603,8 +603,8 @@ export default {
|
||||||
|
|
||||||
APP.store.dispatch(showDesktopSharingButton());
|
APP.store.dispatch(showDesktopSharingButton());
|
||||||
|
|
||||||
APP.remoteControl.init();
|
|
||||||
this._createRoom(tracks);
|
this._createRoom(tracks);
|
||||||
|
APP.remoteControl.init();
|
||||||
|
|
||||||
if (UIUtil.isButtonEnabled('contacts')
|
if (UIUtil.isButtonEnabled('contacts')
|
||||||
&& !interfaceConfig.filmStripOnly) {
|
&& !interfaceConfig.filmStripOnly) {
|
||||||
|
|
|
@ -35,9 +35,7 @@ function initCommands() {
|
||||||
'toggle-share-screen': toggleScreenSharing,
|
'toggle-share-screen': toggleScreenSharing,
|
||||||
'video-hangup': () => APP.conference.hangup(),
|
'video-hangup': () => APP.conference.hangup(),
|
||||||
'email': APP.conference.changeLocalEmail,
|
'email': APP.conference.changeLocalEmail,
|
||||||
'avatar-url': APP.conference.changeLocalAvatarUrl,
|
'avatar-url': APP.conference.changeLocalAvatarUrl
|
||||||
'remote-control-event':
|
|
||||||
event => APP.remoteControl.onRemoteControlAPIEvent(event)
|
|
||||||
};
|
};
|
||||||
transport.on('event', event => {
|
transport.on('event', event => {
|
||||||
const { name, data } = event;
|
const { name, data } = event;
|
||||||
|
@ -237,16 +235,6 @@ class API {
|
||||||
this._sendEvent('video-ready-to-close', {});
|
this._sendEvent('video-ready-to-close', {});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends remote control event.
|
|
||||||
*
|
|
||||||
* @param {RemoteControlEvent} event - The remote control event.
|
|
||||||
* @returns {void}
|
|
||||||
*/
|
|
||||||
sendRemoteControlEvent(event) {
|
|
||||||
this._sendEvent('remote-control-event', event);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disposes the allocated resources.
|
* Disposes the allocated resources.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
/* global APP, JitsiMeetJS, interfaceConfig */
|
/* global APP, JitsiMeetJS, interfaceConfig, config */
|
||||||
const logger = require("jitsi-meet-logger").getLogger(__filename);
|
|
||||||
import {DISCO_REMOTE_CONTROL_FEATURE, REMOTE_CONTROL_EVENT_TYPE, EVENT_TYPES,
|
|
||||||
PERMISSIONS_ACTIONS} from "../../service/remotecontrol/Constants";
|
|
||||||
import RemoteControlParticipant from "./RemoteControlParticipant";
|
|
||||||
import * as JitsiMeetConferenceEvents from '../../ConferenceEvents';
|
import * as JitsiMeetConferenceEvents from '../../ConferenceEvents';
|
||||||
|
import {
|
||||||
|
DISCO_REMOTE_CONTROL_FEATURE,
|
||||||
|
EVENT_TYPES,
|
||||||
|
PERMISSIONS_ACTIONS,
|
||||||
|
REMOTE_CONTROL_EVENT_TYPE
|
||||||
|
} from "../../service/remotecontrol/Constants";
|
||||||
|
import { transport } from '../transport';
|
||||||
|
|
||||||
|
import RemoteControlParticipant from "./RemoteControlParticipant";
|
||||||
|
|
||||||
|
const logger = require("jitsi-meet-logger").getLogger(__filename);
|
||||||
const ConferenceEvents = JitsiMeetJS.events.conference;
|
const ConferenceEvents = JitsiMeetJS.events.conference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,13 +31,24 @@ export default class Receiver extends RemoteControlParticipant {
|
||||||
= this._onRemoteControlEvent.bind(this);
|
= this._onRemoteControlEvent.bind(this);
|
||||||
this._userLeftListener = this._onUserLeft.bind(this);
|
this._userLeftListener = this._onUserLeft.bind(this);
|
||||||
this._hangupListener = this._onHangup.bind(this);
|
this._hangupListener = this._onHangup.bind(this);
|
||||||
|
// We expect here that even if we receive the supported event earlier
|
||||||
|
// it will be cached and we'll receive it.
|
||||||
|
transport.on('event', data => {
|
||||||
|
if(data.name === REMOTE_CONTROL_EVENT_TYPE) {
|
||||||
|
this._onRemoteControlAPIEvent(data.event);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables / Disables the remote control
|
* Enables / Disables the remote control
|
||||||
* @param {boolean} enabled the new state.
|
* @param {boolean} enabled the new state.
|
||||||
*/
|
*/
|
||||||
enable(enabled) {
|
_enable(enabled) {
|
||||||
if(this.enabled === enabled) {
|
if(this.enabled === enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -73,8 +90,11 @@ export default class Receiver extends RemoteControlParticipant {
|
||||||
this.controller = null;
|
this.controller = null;
|
||||||
APP.conference.removeConferenceListener(ConferenceEvents.USER_LEFT,
|
APP.conference.removeConferenceListener(ConferenceEvents.USER_LEFT,
|
||||||
this._userLeftListener);
|
this._userLeftListener);
|
||||||
APP.API.sendRemoteControlEvent({
|
transport.sendEvent({
|
||||||
type: EVENT_TYPES.stop
|
name: REMOTE_CONTROL_EVENT_TYPE,
|
||||||
|
event: {
|
||||||
|
type: EVENT_TYPES.stop
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if(!dontShowDialog) {
|
if(!dontShowDialog) {
|
||||||
APP.UI.messageHandler.openMessageDialog(
|
APP.UI.messageHandler.openMessageDialog(
|
||||||
|
@ -113,6 +133,7 @@ export default class Receiver extends RemoteControlParticipant {
|
||||||
if(this.controller === null
|
if(this.controller === null
|
||||||
&& remoteControlEvent.type === EVENT_TYPES.permissions
|
&& remoteControlEvent.type === EVENT_TYPES.permissions
|
||||||
&& remoteControlEvent.action === PERMISSIONS_ACTIONS.request) {
|
&& remoteControlEvent.action === PERMISSIONS_ACTIONS.request) {
|
||||||
|
// FIXME: Maybe use transport.sendRequest in this case???
|
||||||
remoteControlEvent.userId = participant.getId();
|
remoteControlEvent.userId = participant.getId();
|
||||||
remoteControlEvent.userJID = participant.getJid();
|
remoteControlEvent.userJID = participant.getJid();
|
||||||
remoteControlEvent.displayName = participant.getDisplayName()
|
remoteControlEvent.displayName = participant.getDisplayName()
|
||||||
|
@ -125,7 +146,10 @@ export default class Receiver extends RemoteControlParticipant {
|
||||||
this._stop();
|
this._stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
APP.API.sendRemoteControlEvent(remoteControlEvent);
|
transport.sendEvent({
|
||||||
|
name: REMOTE_CONTROL_EVENT_TYPE,
|
||||||
|
event: remoteControlEvent
|
||||||
|
});
|
||||||
} else if(event.type === REMOTE_CONTROL_EVENT_TYPE) {
|
} else if(event.type === REMOTE_CONTROL_EVENT_TYPE) {
|
||||||
logger.log("Remote control event is ignored because remote "
|
logger.log("Remote control event is ignored because remote "
|
||||||
+ "control is disabled", event);
|
+ "control is disabled", event);
|
||||||
|
@ -133,7 +157,7 @@ export default class Receiver extends RemoteControlParticipant {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles remote control permission events received from the API module.
|
* Handles remote control permission events.
|
||||||
* @param {String} userId the user id of the participant related to the
|
* @param {String} userId the user id of the participant related to the
|
||||||
* event.
|
* event.
|
||||||
* @param {PERMISSIONS_ACTIONS} action the action related to the event.
|
* @param {PERMISSIONS_ACTIONS} action the action related to the event.
|
||||||
|
@ -173,6 +197,36 @@ export default class Receiver extends RemoteControlParticipant {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles remote control events from the external app. Currently only
|
||||||
|
* events with type = EVENT_TYPES.supported or EVENT_TYPES.permissions
|
||||||
|
* @param {RemoteControlEvent} event the remote control event.
|
||||||
|
*/
|
||||||
|
_onRemoteControlAPIEvent(event) {
|
||||||
|
switch(event.type) {
|
||||||
|
case EVENT_TYPES.supported:
|
||||||
|
this._onRemoteControlSupported();
|
||||||
|
break;
|
||||||
|
case EVENT_TYPES.permissions:
|
||||||
|
this._onRemoteControlPermissionsEvent(
|
||||||
|
event.userId, event.action);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles events for support for executing remote control events into
|
||||||
|
* the wrapper application.
|
||||||
|
*/
|
||||||
|
_onRemoteControlSupported() {
|
||||||
|
logger.log("Remote Control supported.");
|
||||||
|
if(!config.disableRemoteControl) {
|
||||||
|
this._enable(true);
|
||||||
|
} else {
|
||||||
|
logger.log("Remote Control disabled.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls the stop method if the other side have left.
|
* Calls the stop method if the other side have left.
|
||||||
* @param {string} id - the user id for the participant that have left
|
* @param {string} id - the user id for the participant that have left
|
||||||
|
@ -187,6 +241,6 @@ export default class Receiver extends RemoteControlParticipant {
|
||||||
* Handles hangup events. Disables the receiver.
|
* Handles hangup events. Disables the receiver.
|
||||||
*/
|
*/
|
||||||
_onHangup() {
|
_onHangup() {
|
||||||
this.enable(false);
|
this._enable(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
/* global APP, config */
|
/* global APP, config */
|
||||||
const logger = require("jitsi-meet-logger").getLogger(__filename);
|
import { DISCO_REMOTE_CONTROL_FEATURE }
|
||||||
import Controller from "./Controller";
|
from '../../service/remotecontrol/Constants';
|
||||||
import Receiver from "./Receiver";
|
|
||||||
import {EVENT_TYPES, DISCO_REMOTE_CONTROL_FEATURE}
|
import Controller from './Controller';
|
||||||
from "../../service/remotecontrol/Constants";
|
import Receiver from './Receiver';
|
||||||
|
|
||||||
|
const logger = require('jitsi-meet-logger').getLogger(__filename);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements the remote control functionality.
|
* Implements the remote control functionality.
|
||||||
|
@ -15,14 +17,12 @@ class RemoteControl {
|
||||||
*/
|
*/
|
||||||
constructor() {
|
constructor() {
|
||||||
this.controller = new Controller();
|
this.controller = new Controller();
|
||||||
this.receiver = new Receiver();
|
|
||||||
this.enabled = false;
|
|
||||||
this.initialized = false;
|
this.initialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the remote control - checks if the remote control should be
|
* Initializes the remote control - checks if the remote control should be
|
||||||
* enabled or not, initializes the API module.
|
* enabled or not.
|
||||||
*/
|
*/
|
||||||
init() {
|
init() {
|
||||||
if(config.disableRemoteControl || this.initialized
|
if(config.disableRemoteControl || this.initialized
|
||||||
|
@ -31,46 +31,8 @@ class RemoteControl {
|
||||||
}
|
}
|
||||||
logger.log("Initializing remote control.");
|
logger.log("Initializing remote control.");
|
||||||
this.initialized = true;
|
this.initialized = true;
|
||||||
APP.API.init({
|
|
||||||
forceEnable: true,
|
|
||||||
});
|
|
||||||
this.controller.enable(true);
|
this.controller.enable(true);
|
||||||
if(this.enabled) { // supported message came before init.
|
this.receiver = new Receiver();
|
||||||
this._onRemoteControlSupported();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles remote control events from the API module. Currently only events
|
|
||||||
* with type = EVENT_TYPES.supported or EVENT_TYPES.permissions
|
|
||||||
* @param {RemoteControlEvent} event the remote control event.
|
|
||||||
*/
|
|
||||||
onRemoteControlAPIEvent(event) {
|
|
||||||
switch(event.type) {
|
|
||||||
case EVENT_TYPES.supported:
|
|
||||||
this._onRemoteControlSupported();
|
|
||||||
break;
|
|
||||||
case EVENT_TYPES.permissions:
|
|
||||||
this.receiver._onRemoteControlPermissionsEvent(
|
|
||||||
event.userId, event.action);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles API event for support for executing remote control events into
|
|
||||||
* the wrapper application.
|
|
||||||
*/
|
|
||||||
_onRemoteControlSupported() {
|
|
||||||
logger.log("Remote Control supported.");
|
|
||||||
if(!config.disableRemoteControl) {
|
|
||||||
this.enabled = true;
|
|
||||||
if(this.initialized) {
|
|
||||||
this.receiver.enable(true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logger.log("Remote Control disabled.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue