From 1368f4059ff1bdbb2cbe0f93b7929bf979ebcadd Mon Sep 17 00:00:00 2001 From: Arash Koushkebaghi Date: Wed, 15 Jan 2020 14:28:44 -0800 Subject: [PATCH] feat(MeetingSdkAdapter): implement exitControl method --- src/MeetingsSDKAdapter.js | 27 +++++++++++++++++++++++++++ src/MeetingsSDKAdapter.test.js | 14 ++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/MeetingsSDKAdapter.js b/src/MeetingsSDKAdapter.js index bb352b29..7357bbb1 100644 --- a/src/MeetingsSDKAdapter.js +++ b/src/MeetingsSDKAdapter.js @@ -6,6 +6,7 @@ const EVENT_MEDIA_READY = 'media:ready'; const EVENT_MEDIA_STOPPED = 'media:stopped'; const EVENT_MEDIA_LOCAL_UPDATE = 'adapter:media:local:update'; const JOIN_CONTROL = 'join-meeting'; +const EXIT_CONTROL = 'leave-meeting'; const AUDIO_CONTROL = 'audio'; const VIDEO_CONTROL = 'video'; const MEDIA_TYPE_LOCAL = 'local'; @@ -51,6 +52,12 @@ export default class MeetingsSDKAdapter extends MeetingsAdapter { action: this.handleLocalVideo.bind(this), display: this.videoControl.bind(this), }; + + this.meetingControls[EXIT_CONTROL] = { + ID: EXIT_CONTROL, + action: this.leaveMeeting.bind(this), + display: this.exitControl.bind(this), + }; } /** @@ -251,6 +258,26 @@ export default class MeetingsSDKAdapter extends MeetingsAdapter { }); } + /** + * Returns an observable that emits the display data of a meeting control. + * + * @returns {Observable.} + * @memberof MeetingJSONAdapter + * @private + */ + exitControl() { + return Observable.create((observer) => { + observer.next({ + ID: EXIT_CONTROL, + icon: 'cancel', + tooltip: 'Leave', + state: MeetingControlState.ACTIVE, + }); + + observer.complete(); + }); + } + /** * Attempts to mute the microphone of the given meeting ID. * If the microphone is successfully muted, an audio mute event is dispatched. diff --git a/src/MeetingsSDKAdapter.test.js b/src/MeetingsSDKAdapter.test.js index 46cb31fb..6fde439d 100644 --- a/src/MeetingsSDKAdapter.test.js +++ b/src/MeetingsSDKAdapter.test.js @@ -182,6 +182,20 @@ describe('Meetings SDK Adapter', () => { }); }); + describe('exitControl()', () => { + test('returns the display data of a meeting control in a proper shape', (done) => { + meetingSDKAdapter.exitControl().subscribe((dataDisplay) => { + expect(dataDisplay).toMatchObject({ + ID: 'leave-meeting', + icon: 'cancel', + tooltip: 'Leave', + state: 'active', + }); + done(); + }); + }); + }); + describe('audioControl()', () => { test('returns the display data of a meeting control in a proper shape', (done) => { meetingSDKAdapter.audioControl(meetingID).subscribe((dataDisplay) => {