浏览代码

feat(iframeAPI): implement avatar change commands

j8
hristoterezov 8 年前
父节点
当前提交
f7ce8d028d
共有 4 个文件被更改,包括 61 次插入35 次删除
  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 查看文件

263
                 'failed to create local tracks', options.devices, err);
263
                 'failed to create local tracks', options.devices, err);
264
             return Promise.reject(err);
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
             APP.UI.initEtherpad(value);
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
         room.addCommandListener(this.commands.defaults.EMAIL, (data, from) => {
1391
         room.addCommandListener(this.commands.defaults.EMAIL, (data, from) => {
1408
             APP.UI.setUserEmail(from, data.value);
1392
             APP.UI.setUserEmail(from, data.value);
1409
         });
1393
         });
1802
             APP.API.notifyReadyToClose();
1786
             APP.API.notifyReadyToClose();
1803
             maybeRedirectToWelcomePage(values[0]);
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 查看文件

43
 
43
 
44
 You can send command to Jitsi Meet conference using ```executeCommand```.
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
 The ```command``` parameter is String object with the name of the command.
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
 Currently we support the following commands:
49
 Currently we support the following commands:
52
 
50
 
53
 
51
 
58
 ```
56
 ```
59
 * **toggleAudio** - mutes / unmutes the audio for the local participant. No arguments are required.
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
 * **toggleVideo** - mutes / unmutes the video for the local participant. No arguments are required.
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
 * **toggleFilmStrip** - hides / shows the film strip. No arguments are required.
65
 * **toggleFilmStrip** - hides / shows the film strip. No arguments are required.
68
 ```
66
 ```
69
-api.executeCommand('filmStrip', [])
67
+api.executeCommand('filmStrip')
70
 ```
68
 ```
71
 * **toggleChat** - hides / shows the chat. No arguments are required.
69
 * **toggleChat** - hides / shows the chat. No arguments are required.
72
 ```
70
 ```
73
-api.executeCommand('toggleChat', [])
71
+api.executeCommand('toggleChat')
74
 ```
72
 ```
75
 * **toggleContactList** - hides / shows the contact list. No arguments are required.
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
 * **toggleShareScreen** - starts / stops the screen sharing. No arguments are required.
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
 * **hangup** - Hangups the call. No arguments are required.
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
 You can also execute multiple commands using the method ```executeCommands```.
98
 You can also execute multiple commands using the method ```executeCommands```.

+ 4
- 2
modules/API/API.js 查看文件

54
         "toggle-contact-list": APP.UI.toggleContactList,
54
         "toggle-contact-list": APP.UI.toggleContactList,
55
         "toggle-share-screen":
55
         "toggle-share-screen":
56
             APP.conference.toggleScreenSharing.bind(APP.conference),
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
     Object.keys(commands).forEach(function (key) {
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 查看文件

36
     "toggleChat": "toggle-chat",
36
     "toggleChat": "toggle-chat",
37
     "toggleContactList": "toggle-contact-list",
37
     "toggleContactList": "toggle-contact-list",
38
     "toggleShareScreen": "toggle-share-screen",
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
  * @param name the name of the command
176
  * @param name the name of the command
175
  * @param arguments array of arguments
177
  * @param arguments array of arguments
176
  */
178
  */
177
-JitsiMeetExternalAPI.prototype.executeCommand = function(name, argumentsList) {
179
+JitsiMeetExternalAPI.prototype.executeCommand
180
+= function(name, ...argumentsList) {
178
     if(!(name in commands)) {
181
     if(!(name in commands)) {
179
         logger.error("Not supported command name.");
182
         logger.error("Not supported command name.");
180
         return;
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
 /**

正在加载...
取消
保存