Bläddra i källkod

feat(iframeAPI): implement avatar change commands

j8
hristoterezov 8 år sedan
förälder
incheckning
f7ce8d028d
4 ändrade filer med 61 tillägg och 35 borttagningar
  1. 33
    17
      conference.js
  2. 18
    10
      doc/api.md
  3. 4
    2
      modules/API/API.js
  4. 6
    6
      modules/API/external/external_api.js

+ 33
- 17
conference.js Visa fil

@@ -263,22 +263,6 @@ function createLocalTracks (options, checkForPermissionPrompt) {
263 263
                 'failed to create local tracks', options.devices, err);
264 264
             return Promise.reject(err);
265 265
         });
266
-    }
267
-
268
-/**
269
- * Changes the email for the local user
270
- * @param email {string} the new email
271
- */
272
-function changeLocalEmail(email = '') {
273
-    email = email.trim();
274
-
275
-    if (email === APP.settings.getEmail()) {
276
-        return;
277
-    }
278
-
279
-    APP.settings.setEmail(email);
280
-    APP.UI.setUserEmail(room.myUserId(), email);
281
-    sendData(commands.EMAIL, email);
282 266
 }
283 267
 
284 268
 /**
@@ -1403,7 +1387,7 @@ export default {
1403 1387
             APP.UI.initEtherpad(value);
1404 1388
         });
1405 1389
 
1406
-        APP.UI.addListener(UIEvents.EMAIL_CHANGED, changeLocalEmail);
1390
+        APP.UI.addListener(UIEvents.EMAIL_CHANGED, this.changeLocalEmail);
1407 1391
         room.addCommandListener(this.commands.defaults.EMAIL, (data, from) => {
1408 1392
             APP.UI.setUserEmail(from, data.value);
1409 1393
         });
@@ -1802,5 +1786,37 @@ export default {
1802 1786
             APP.API.notifyReadyToClose();
1803 1787
             maybeRedirectToWelcomePage(values[0]);
1804 1788
         });
1789
+    },
1790
+
1791
+    /**
1792
+     * Changes the email for the local user
1793
+     * @param email {string} the new email
1794
+     */
1795
+    changeLocalEmail(email = '') {
1796
+        email = email.trim();
1797
+
1798
+        if (email === APP.settings.getEmail()) {
1799
+            return;
1800
+        }
1801
+
1802
+        APP.settings.setEmail(email);
1803
+        APP.UI.setUserEmail(room.myUserId(), email);
1804
+        sendData(commands.EMAIL, email);
1805
+    },
1806
+
1807
+    /**
1808
+     * Changes the avatar url for the local user
1809
+     * @param url {string} the new url
1810
+     */
1811
+    changeLocalAvatarUrl(url = '') {
1812
+        url = url.trim();
1813
+
1814
+        if (url === APP.settings.getAvatarUrl()) {
1815
+            return;
1816
+        }
1817
+
1818
+        APP.settings.setAvatarUrl(url);
1819
+        APP.UI.setUserAvatarUrl(room.myUserId(), url);
1820
+        sendData(commands.AVATAR_URL, url);
1805 1821
     }
1806 1822
 };

+ 18
- 10
doc/api.md Visa fil

@@ -43,11 +43,9 @@ You can control the embedded Jitsi Meet conference using the JitsiMeetExternalAP
43 43
 
44 44
 You can send command to Jitsi Meet conference using ```executeCommand```.
45 45
 ```
46
-api.executeCommand(command, arguments)
46
+api.executeCommand(command, ...arguments)
47 47
 ```
48 48
 The ```command``` parameter is String object with the name of the command.
49
-The ```arguments``` parameter is array with the arguments required by the command.
50
-If no arguments are required by the command this parameter can be omitted or you can pass empty array.
51 49
 Currently we support the following commands:
52 50
 
53 51
 
@@ -58,33 +56,43 @@ api.executeCommand('displayName', 'New Nickname');
58 56
 ```
59 57
 * **toggleAudio** - mutes / unmutes the audio for the local participant. No arguments are required.
60 58
 ```
61
-api.executeCommand('toggleAudio', [])
59
+api.executeCommand('toggleAudio')
62 60
 ```
63 61
 * **toggleVideo** - mutes / unmutes the video for the local participant. No arguments are required.
64 62
 ```
65
-api.executeCommand('toggleVideo', [])
63
+api.executeCommand('toggleVideo')
66 64
 ```
67 65
 * **toggleFilmStrip** - hides / shows the film strip. No arguments are required.
68 66
 ```
69
-api.executeCommand('filmStrip', [])
67
+api.executeCommand('filmStrip')
70 68
 ```
71 69
 * **toggleChat** - hides / shows the chat. No arguments are required.
72 70
 ```
73
-api.executeCommand('toggleChat', [])
71
+api.executeCommand('toggleChat')
74 72
 ```
75 73
 * **toggleContactList** - hides / shows the contact list. No arguments are required.
76 74
 ```
77
-api.executeCommand('toggleContactList', [])
75
+api.executeCommand('toggleContactList')
78 76
 ```
79 77
 
80 78
 * **toggleShareScreen** - starts / stops the screen sharing. No arguments are required.
81 79
 ```
82
-api.executeCommand('toggleShareScreen', [])
80
+api.executeCommand('toggleShareScreen')
83 81
 ```
84 82
 
85 83
 * **hangup** - Hangups the call. No arguments are required.
86 84
 ```
87
-api.executeCommand('hangup', [])
85
+api.executeCommand('hangup')
86
+```
87
+
88
+* **email** - Hangups the call. No arguments are required.
89
+```
90
+api.executeCommand('email', 'example@example.com')
91
+```
92
+
93
+* **avatarUrl** - Hangups the call. No arguments are required.
94
+```
95
+api.executeCommand('avatarUrl', 'avatarUrl')
88 96
 ```
89 97
 
90 98
 You can also execute multiple commands using the method ```executeCommands```.

+ 4
- 2
modules/API/API.js Visa fil

@@ -54,10 +54,12 @@ function initCommands() {
54 54
         "toggle-contact-list": APP.UI.toggleContactList,
55 55
         "toggle-share-screen":
56 56
             APP.conference.toggleScreenSharing.bind(APP.conference),
57
-        "video-hangup": () => APP.conference.hangup()
57
+        "video-hangup": () => APP.conference.hangup(),
58
+        "email": APP.conference.changeLocalEmail,
59
+        "avatar-url": APP.conference.changeLocalAvatarUrl
58 60
     };
59 61
     Object.keys(commands).forEach(function (key) {
60
-        postis.listen(key, commands[key]);
62
+        postis.listen(key, args => commands[key](...args));
61 63
     });
62 64
 }
63 65
 

+ 6
- 6
modules/API/external/external_api.js Visa fil

@@ -36,7 +36,9 @@ var commands = {
36 36
     "toggleChat": "toggle-chat",
37 37
     "toggleContactList": "toggle-contact-list",
38 38
     "toggleShareScreen": "toggle-share-screen",
39
-    "hangup": "video-hangup"
39
+    "hangup": "video-hangup",
40
+    "email": "email",
41
+    "avatarUrl": "avatar-url"
40 42
 };
41 43
 
42 44
 /**
@@ -174,15 +176,13 @@ function JitsiMeetExternalAPI(domain, room_name, width, height, parentNode,
174 176
  * @param name the name of the command
175 177
  * @param arguments array of arguments
176 178
  */
177
-JitsiMeetExternalAPI.prototype.executeCommand = function(name, argumentsList) {
179
+JitsiMeetExternalAPI.prototype.executeCommand
180
+= function(name, ...argumentsList) {
178 181
     if(!(name in commands)) {
179 182
         logger.error("Not supported command name.");
180 183
         return;
181 184
     }
182
-    var argumentsArray = argumentsList;
183
-    if (!argumentsArray)
184
-        argumentsArray = [];
185
-    sendMessage(this.postis, {method: commands[name], params: argumentsArray});
185
+    sendMessage(this.postis, {method: commands[name], params: argumentsList});
186 186
 };
187 187
 
188 188
 /**

Laddar…
Avbryt
Spara