|
|
@@ -15,35 +15,15 @@ window.toastr = require("toastr");
|
|
15
|
15
|
|
|
16
|
16
|
import URLProcessor from "./modules/config/URLProcessor";
|
|
17
|
17
|
import RoomnameGenerator from './modules/util/RoomnameGenerator';
|
|
18
|
|
-import CQEvents from './service/connectionquality/CQEvents';
|
|
19
|
|
-import UIEvents from './service/UI/UIEvents';
|
|
20
|
|
-import DSEvents from './service/desktopsharing/DesktopSharingEventTypes';
|
|
21
|
18
|
|
|
22
|
19
|
import UI from "./modules/UI/UI";
|
|
23
|
20
|
import statistics from "./modules/statistics/statistics";
|
|
24
|
21
|
import settings from "./modules/settings/Settings";
|
|
|
22
|
+import UIEvents from './service/UI/UIEvents';
|
|
25
|
23
|
|
|
26
|
|
-import {openConnection} from './modules/connection';
|
|
27
|
|
-import AuthHandler from './modules/AuthHandler';
|
|
28
|
|
-
|
|
29
|
|
-import createRoomLocker from './modules/RoomLocker';
|
|
30
|
|
-
|
|
31
|
|
-const ConnectionEvents = JitsiMeetJS.events.connection;
|
|
32
|
|
-const ConnectionErrors = JitsiMeetJS.errors.connection;
|
|
33
|
|
-
|
|
34
|
|
-const ConferenceEvents = JitsiMeetJS.events.conference;
|
|
35
|
|
-const ConferenceErrors = JitsiMeetJS.errors.conference;
|
|
|
24
|
+import conference from './conference';
|
|
36
|
25
|
|
|
37
|
|
-let localVideo, localAudio;
|
|
38
|
26
|
|
|
39
|
|
-const Commands = {
|
|
40
|
|
- CONNECTION_QUALITY: "stats",
|
|
41
|
|
- EMAIL: "email",
|
|
42
|
|
- VIDEO_TYPE: "videoType",
|
|
43
|
|
- ETHERPAD: "etherpad",
|
|
44
|
|
- PREZI: "prezi",
|
|
45
|
|
- STOP_PREZI: "stop-prezi"
|
|
46
|
|
-};
|
|
47
|
27
|
|
|
48
|
28
|
function buildRoomName () {
|
|
49
|
29
|
let path = window.location.pathname;
|
|
|
@@ -77,66 +57,12 @@ function buildRoomName () {
|
|
77
|
57
|
return roomName;
|
|
78
|
58
|
}
|
|
79
|
59
|
|
|
80
|
|
-
|
|
81
|
60
|
const APP = {
|
|
82
|
61
|
UI,
|
|
83
|
62
|
statistics,
|
|
84
|
63
|
settings,
|
|
85
|
|
-
|
|
86
|
|
- createLocalTracks (...devices) {
|
|
87
|
|
- return JitsiMeetJS.createLocalTracks({
|
|
88
|
|
- // copy array to avoid mutations inside library
|
|
89
|
|
- devices: devices.slice(0),
|
|
90
|
|
- resolution: config.resolution
|
|
91
|
|
- }).catch(function (err) {
|
|
92
|
|
- console.error('failed to create local tracks', ...devices, err);
|
|
93
|
|
- APP.statistics.onGetUserMediaFailed(err);
|
|
94
|
|
- return [];
|
|
95
|
|
- });
|
|
96
|
|
- },
|
|
97
|
|
-
|
|
98
|
64
|
init () {
|
|
99
|
|
- let roomName = buildRoomName();
|
|
100
|
|
- this.conference = {
|
|
101
|
|
- roomName,
|
|
102
|
|
- localId: undefined,
|
|
103
|
|
- isModerator: false,
|
|
104
|
|
- membersCount: 0,
|
|
105
|
|
- audioMuted: false,
|
|
106
|
|
- videoMuted: false,
|
|
107
|
|
- isLocalId (id) {
|
|
108
|
|
- return this.localId === id;
|
|
109
|
|
- },
|
|
110
|
|
- muteAudio (mute) {
|
|
111
|
|
- APP.UI.eventEmitter.emit(UIEvents.AUDIO_MUTED, mute);
|
|
112
|
|
- APP.statistics.onAudioMute(mute);
|
|
113
|
|
- },
|
|
114
|
|
- toggleAudioMuted () {
|
|
115
|
|
- this.muteAudio(!this.audioMuted);
|
|
116
|
|
- },
|
|
117
|
|
- muteVideo (mute) {
|
|
118
|
|
- APP.UI.eventEmitter.emit(UIEvents.VIDEO_MUTED, mute);
|
|
119
|
|
- APP.statistics.onVideoMute(mute);
|
|
120
|
|
- },
|
|
121
|
|
- toggleVideoMuted () {
|
|
122
|
|
- this.muteVideo(!this.videoMuted);
|
|
123
|
|
- },
|
|
124
|
|
-
|
|
125
|
|
- // used by torture currently
|
|
126
|
|
- isJoined () {
|
|
127
|
|
- return APP.conference._room
|
|
128
|
|
- && APP.conference._room.isJoined();
|
|
129
|
|
- },
|
|
130
|
|
- getConnectionState () {
|
|
131
|
|
- return APP.conference._room
|
|
132
|
|
- && APP.conference._room.getConnectionState();
|
|
133
|
|
- },
|
|
134
|
|
- getMyUserId () {
|
|
135
|
|
- return APP.conference._room
|
|
136
|
|
- && APP.conference._room.myUserId();
|
|
137
|
|
- }
|
|
138
|
|
- };
|
|
139
|
|
-
|
|
|
65
|
+ this.conference = conference;
|
|
140
|
66
|
this.API = require("./modules/API/API");
|
|
141
|
67
|
this.connectionquality =
|
|
142
|
68
|
require("./modules/connectionquality/connectionquality");
|
|
|
@@ -149,524 +75,9 @@ const APP = {
|
|
149
|
75
|
}
|
|
150
|
76
|
};
|
|
151
|
77
|
|
|
152
|
|
-function initConference(localTracks, connection) {
|
|
153
|
|
- let options = {
|
|
154
|
|
- openSctp: config.openSctp,
|
|
155
|
|
- disableAudioLevels: config.disableAudioLevels
|
|
156
|
|
- };
|
|
157
|
|
- if(config.enableRecording) {
|
|
158
|
|
- options.recordingType = (config.hosts &&
|
|
159
|
|
- (typeof config.hosts.jirecon != "undefined"))?
|
|
160
|
|
- "jirecon" : "colibri";
|
|
161
|
|
- }
|
|
162
|
|
- let room = connection.initJitsiConference(APP.conference.roomName, options);
|
|
163
|
|
- APP.conference._room = room; // FIXME do not use this
|
|
164
|
|
-
|
|
165
|
|
- const addTrack = (track) => {
|
|
166
|
|
- room.addTrack(track);
|
|
167
|
|
- if (track.isAudioTrack()) {
|
|
168
|
|
- return;
|
|
169
|
|
- }
|
|
170
|
|
-
|
|
171
|
|
- room.removeCommand(Commands.VIDEO_TYPE);
|
|
172
|
|
- room.sendCommand(Commands.VIDEO_TYPE, {
|
|
173
|
|
- value: track.videoType,
|
|
174
|
|
- attributes: {
|
|
175
|
|
- xmlns: 'http://jitsi.org/jitmeet/video'
|
|
176
|
|
- }
|
|
177
|
|
- });
|
|
178
|
|
- };
|
|
179
|
|
-
|
|
180
|
|
- APP.conference.localId = room.myUserId();
|
|
181
|
|
- Object.defineProperty(APP.conference, "membersCount", {
|
|
182
|
|
- get: function () {
|
|
183
|
|
- return room.getParticipants().length; // FIXME maybe +1?
|
|
184
|
|
- }
|
|
185
|
|
- });
|
|
186
|
|
-
|
|
187
|
|
- APP.conference.listMembers = function () {
|
|
188
|
|
- return room.getParticipants();
|
|
189
|
|
- };
|
|
190
|
|
- APP.conference.listMembersIds = function () {
|
|
191
|
|
- return room.getParticipants().map(p => p.getId());
|
|
192
|
|
- };
|
|
193
|
|
-
|
|
194
|
|
- APP.conference.sipGatewayEnabled = () => {
|
|
195
|
|
- return room.isSIPCallingSupported();
|
|
196
|
|
- };
|
|
197
|
|
-
|
|
198
|
|
- function getDisplayName(id) {
|
|
199
|
|
- if (APP.conference.isLocalId(id)) {
|
|
200
|
|
- return APP.settings.getDisplayName();
|
|
201
|
|
- }
|
|
202
|
|
-
|
|
203
|
|
- let participant = room.getParticipantById(id);
|
|
204
|
|
- if (participant && participant.getDisplayName()) {
|
|
205
|
|
- return participant.getDisplayName();
|
|
206
|
|
- }
|
|
207
|
|
- }
|
|
208
|
|
-
|
|
209
|
|
- // add local streams when joined to the conference
|
|
210
|
|
- room.on(ConferenceEvents.CONFERENCE_JOINED, function () {
|
|
211
|
|
- localTracks.forEach(function (track) {
|
|
212
|
|
- if(track.isAudioTrack()) {
|
|
213
|
|
- localAudio = track;
|
|
214
|
|
- }
|
|
215
|
|
- else if (track.isVideoTrack()) {
|
|
216
|
|
- localVideo = track;
|
|
217
|
|
- }
|
|
218
|
|
- addTrack(track);
|
|
219
|
|
- APP.UI.addLocalStream(track);
|
|
220
|
|
- });
|
|
221
|
|
-
|
|
222
|
|
- APP.UI.updateAuthInfo(room.isAuthEnabled(), room.getAuthLogin());
|
|
223
|
|
- });
|
|
224
|
|
-
|
|
225
|
|
-
|
|
226
|
|
- room.on(ConferenceEvents.USER_JOINED, function (id, user) {
|
|
227
|
|
- console.log('USER %s connnected', id, user);
|
|
228
|
|
- // FIXME email???
|
|
229
|
|
- APP.UI.addUser(id, user.getDisplayName());
|
|
230
|
|
- });
|
|
231
|
|
- room.on(ConferenceEvents.USER_LEFT, function (id, user) {
|
|
232
|
|
- console.log('USER %s LEFT', id, user);
|
|
233
|
|
- APP.UI.removeUser(id, user.getDisplayName());
|
|
234
|
|
- APP.UI.stopPrezi(id);
|
|
235
|
|
- });
|
|
236
|
|
-
|
|
237
|
|
-
|
|
238
|
|
- room.on(ConferenceEvents.USER_ROLE_CHANGED, function (id, role) {
|
|
239
|
|
- if (APP.conference.isLocalId(id)) {
|
|
240
|
|
- console.info(`My role changed, new role: ${role}`);
|
|
241
|
|
- APP.conference.isModerator = room.isModerator();
|
|
242
|
|
- APP.UI.updateLocalRole(room.isModerator());
|
|
243
|
|
- } else {
|
|
244
|
|
- let user = room.getParticipantById(id);
|
|
245
|
|
- if (user) {
|
|
246
|
|
- APP.UI.updateUserRole(user);
|
|
247
|
|
- }
|
|
248
|
|
- }
|
|
249
|
|
- });
|
|
250
|
|
-
|
|
251
|
|
-
|
|
252
|
|
- let roomLocker = createRoomLocker(room);
|
|
253
|
|
- APP.UI.addListener(UIEvents.ROOM_LOCK_CLICKED, function () {
|
|
254
|
|
- if (room.isModerator()) {
|
|
255
|
|
- let promise = roomLocker.isLocked
|
|
256
|
|
- ? roomLocker.askToUnlock()
|
|
257
|
|
- : roomLocker.askToLock();
|
|
258
|
|
- promise.then(function () {
|
|
259
|
|
- APP.UI.markRoomLocked(roomLocker.isLocked);
|
|
260
|
|
- });
|
|
261
|
|
- } else {
|
|
262
|
|
- roomLocker.notifyModeratorRequired();
|
|
263
|
|
- }
|
|
264
|
|
- });
|
|
265
|
|
-
|
|
266
|
|
-
|
|
267
|
|
- room.on(ConferenceEvents.TRACK_ADDED, function (track) {
|
|
268
|
|
- if (track.isLocal()) { // skip local tracks
|
|
269
|
|
- return;
|
|
270
|
|
- }
|
|
271
|
|
- console.log(
|
|
272
|
|
- 'REMOTE %s TRACK', track.getType(), track.getParticipantId()
|
|
273
|
|
- );
|
|
274
|
|
- APP.UI.addRemoteStream(track);
|
|
275
|
|
- });
|
|
276
|
|
- room.on(ConferenceEvents.TRACK_REMOVED, function (track) {
|
|
277
|
|
- if (track.isLocal()) { // skip local tracks
|
|
278
|
|
- return;
|
|
279
|
|
- }
|
|
280
|
|
-
|
|
281
|
|
- console.log(
|
|
282
|
|
- 'REMOTE %s TRACK REMOVED', track.getType(), track.getParticipantId()
|
|
283
|
|
- );
|
|
284
|
|
-
|
|
285
|
|
- // FIXME handle
|
|
286
|
|
- });
|
|
287
|
|
- room.on(ConferenceEvents.TRACK_MUTE_CHANGED, function (track) {
|
|
288
|
|
- // FIXME handle mute
|
|
289
|
|
- });
|
|
290
|
|
- room.on(ConferenceEvents.TRACK_AUDIO_LEVEL_CHANGED, function (id, lvl) {
|
|
291
|
|
- APP.UI.setAudioLevel(id, lvl);
|
|
292
|
|
- });
|
|
293
|
|
- APP.UI.addListener(UIEvents.AUDIO_MUTED, function (muted) {
|
|
294
|
|
- // FIXME mute or unmute
|
|
295
|
|
- APP.UI.setAudioMuted(muted);
|
|
296
|
|
- APP.conference.audioMuted = muted;
|
|
297
|
|
- });
|
|
298
|
|
- APP.UI.addListener(UIEvents.VIDEO_MUTED, function (muted) {
|
|
299
|
|
- // FIXME mute or unmute
|
|
300
|
|
- APP.UI.setVideoMuted(muted);
|
|
301
|
|
- APP.conference.videoMuted = muted;
|
|
302
|
|
- });
|
|
303
|
|
-
|
|
304
|
|
-
|
|
305
|
|
- room.on(ConferenceEvents.IN_LAST_N_CHANGED, function (inLastN) {
|
|
306
|
|
- if (config.muteLocalVideoIfNotInLastN) {
|
|
307
|
|
- // TODO mute or unmute if required
|
|
308
|
|
- // mark video on UI
|
|
309
|
|
- // APP.UI.markVideoMuted(true/false);
|
|
310
|
|
- }
|
|
311
|
|
- });
|
|
312
|
|
- room.on(ConferenceEvents.LAST_N_ENDPOINTS_CHANGED, function (ids) {
|
|
313
|
|
- APP.UI.handleLastNEndpoints(ids);
|
|
314
|
|
- });
|
|
315
|
|
- room.on(ConferenceEvents.ACTIVE_SPEAKER_CHANGED, function (id) {
|
|
316
|
|
- APP.UI.markDominantSpiker(id);
|
|
317
|
|
- });
|
|
318
|
|
-
|
|
319
|
|
-
|
|
320
|
|
- if (!interfaceConfig.filmStripOnly) {
|
|
321
|
|
- room.on(ConferenceEvents.CONNECTION_INTERRUPTED, function () {
|
|
322
|
|
- APP.UI.markVideoInterrupted(true);
|
|
323
|
|
- });
|
|
324
|
|
- room.on(ConferenceEvents.CONNECTION_RESTORED, function () {
|
|
325
|
|
- APP.UI.markVideoInterrupted(false);
|
|
326
|
|
- });
|
|
327
|
|
-
|
|
328
|
|
- APP.UI.addListener(UIEvents.MESSAGE_CREATED, function (message) {
|
|
329
|
|
- room.sendTextMessage(message);
|
|
330
|
|
- });
|
|
331
|
|
- room.on(ConferenceEvents.MESSAGE_RECEIVED, function (id, text, ts) {
|
|
332
|
|
- APP.UI.addMessage(id, getDisplayName(id), text, ts);
|
|
333
|
|
- });
|
|
334
|
|
- }
|
|
335
|
|
-
|
|
336
|
|
- APP.connectionquality.addListener(
|
|
337
|
|
- CQEvents.LOCALSTATS_UPDATED,
|
|
338
|
|
- function (percent, stats) {
|
|
339
|
|
- APP.UI.updateLocalStats(percent, stats);
|
|
340
|
|
-
|
|
341
|
|
- // send local stats to other users
|
|
342
|
|
- room.sendCommandOnce(Commands.CONNECTION_QUALITY, {
|
|
343
|
|
- children: APP.connectionquality.convertToMUCStats(stats),
|
|
344
|
|
- attributes: {
|
|
345
|
|
- xmlns: 'http://jitsi.org/jitmeet/stats'
|
|
346
|
|
- }
|
|
347
|
|
- });
|
|
348
|
|
- }
|
|
349
|
|
- );
|
|
350
|
|
- APP.connectionquality.addListener(CQEvents.STOP, function () {
|
|
351
|
|
- APP.UI.hideStats();
|
|
352
|
|
- room.removeCommand(Commands.CONNECTION_QUALITY);
|
|
353
|
|
- });
|
|
354
|
|
- // listen to remote stats
|
|
355
|
|
- room.addCommandListener(
|
|
356
|
|
- Commands.CONNECTION_QUALITY,
|
|
357
|
|
- function (values, from) {
|
|
358
|
|
- APP.connectionquality.updateRemoteStats(from, values);
|
|
359
|
|
- }
|
|
360
|
|
- );
|
|
361
|
|
- APP.connectionquality.addListener(
|
|
362
|
|
- CQEvents.REMOTESTATS_UPDATED,
|
|
363
|
|
- function (id, percent, stats) {
|
|
364
|
|
- APP.UI.updateRemoteStats(id, percent, stats);
|
|
365
|
|
- }
|
|
366
|
|
- );
|
|
367
|
|
-
|
|
368
|
|
- room.addCommandListener(Commands.ETHERPAD, function ({value}) {
|
|
369
|
|
- APP.UI.initEtherpad(value);
|
|
370
|
|
- });
|
|
371
|
|
-
|
|
372
|
|
-
|
|
373
|
|
- room.addCommandListener(Commands.PREZI, function ({value, attributes}) {
|
|
374
|
|
- APP.UI.showPrezi(attributes.id, value, attributes.slide);
|
|
375
|
|
- });
|
|
376
|
|
- room.addCommandListener(Commands.STOP_PREZI, function ({attributes}) {
|
|
377
|
|
- APP.UI.stopPrezi(attributes.id);
|
|
378
|
|
- });
|
|
379
|
|
- APP.UI.addListener(UIEvents.SHARE_PREZI, function (url, slide) {
|
|
380
|
|
- console.log('Sharing Prezi %s slide %s', url, slide);
|
|
381
|
|
- room.removeCommand(Commands.PREZI);
|
|
382
|
|
- room.sendCommand(Commands.PREZI, {
|
|
383
|
|
- value: url,
|
|
384
|
|
- attributes: {
|
|
385
|
|
- id: room.myUserId(),
|
|
386
|
|
- slide
|
|
387
|
|
- }
|
|
388
|
|
- });
|
|
389
|
|
- });
|
|
390
|
|
- APP.UI.addListener(UIEvents.STOP_SHARING_PREZI, function () {
|
|
391
|
|
- room.removeCommand(Commands.PREZI);
|
|
392
|
|
- room.sendCommandOnce(Commands.STOP_PREZI, {
|
|
393
|
|
- attributes: {
|
|
394
|
|
- id: room.myUserId()
|
|
395
|
|
- }
|
|
396
|
|
- });
|
|
397
|
|
- });
|
|
398
|
|
-
|
|
399
|
|
- room.addCommandListener(Commands.VIDEO_TYPE, ({value}, from) => {
|
|
400
|
|
- APP.UI.onPeerVideoTypeChanged(from, value);
|
|
401
|
|
- });
|
|
402
|
|
-
|
|
403
|
|
-
|
|
404
|
|
- // share email with other users
|
|
405
|
|
- function sendEmail(email) {
|
|
406
|
|
- room.sendCommand(Commands.EMAIL, {
|
|
407
|
|
- value: email,
|
|
408
|
|
- attributes: {
|
|
409
|
|
- id: room.myUserId()
|
|
410
|
|
- }
|
|
411
|
|
- });
|
|
412
|
|
- }
|
|
413
|
|
-
|
|
414
|
|
- let email = APP.settings.getEmail();
|
|
415
|
|
- email && sendEmail(email);
|
|
416
|
|
- APP.UI.addListener(UIEvents.EMAIL_CHANGED, function (email) {
|
|
417
|
|
- APP.settings.setEmail(email);
|
|
418
|
|
- APP.UI.setUserAvatar(room.myUserId(), email);
|
|
419
|
|
- sendEmail(email);
|
|
420
|
|
- });
|
|
421
|
|
- room.addCommandListener(Commands.EMAIL, function (data) {
|
|
422
|
|
- APP.UI.setUserAvatar(data.attributes.id, data.value);
|
|
423
|
|
- });
|
|
424
|
|
-
|
|
425
|
|
- let nick = APP.settings.getDisplayName();
|
|
426
|
|
- if (config.useNicks && !nick) {
|
|
427
|
|
- nick = APP.UI.askForNickname();
|
|
428
|
|
- APP.settings.setDisplayName(nick);
|
|
429
|
|
- }
|
|
430
|
|
-
|
|
431
|
|
- if (nick) {
|
|
432
|
|
- room.setDisplayName(nick);
|
|
433
|
|
- }
|
|
434
|
|
- room.on(ConferenceEvents.DISPLAY_NAME_CHANGED, function (id, displayName) {
|
|
435
|
|
- APP.UI.changeDisplayName(id, displayName);
|
|
436
|
|
- });
|
|
437
|
|
-
|
|
438
|
|
- room.on(ConferenceEvents.RECORDING_STATE_CHANGED, (status, error) => {
|
|
439
|
|
- if(status == "error") {
|
|
440
|
|
- console.error(error);
|
|
441
|
|
- return;
|
|
442
|
|
- }
|
|
443
|
|
- APP.UI.updateRecordingState(status);
|
|
444
|
|
- });
|
|
445
|
|
-
|
|
446
|
|
- APP.UI.addListener(UIEvents.NICKNAME_CHANGED, function (nickname) {
|
|
447
|
|
- APP.settings.setDisplayName(nickname);
|
|
448
|
|
- room.setDisplayName(nickname);
|
|
449
|
|
- APP.UI.changeDisplayName(APP.conference.localId, nickname);
|
|
450
|
|
- });
|
|
451
|
|
-
|
|
452
|
|
- APP.UI.addListener(
|
|
453
|
|
- UIEvents.START_MUTED_CHANGED,
|
|
454
|
|
- function (startAudioMuted, startVideoMuted) {
|
|
455
|
|
- // FIXME start muted
|
|
456
|
|
- }
|
|
457
|
|
- );
|
|
458
|
|
-
|
|
459
|
|
- APP.UI.addListener(UIEvents.USER_INVITED, function (roomUrl) {
|
|
460
|
|
- APP.UI.inviteParticipants(
|
|
461
|
|
- roomUrl,
|
|
462
|
|
- APP.conference.roomName,
|
|
463
|
|
- roomLocker.password,
|
|
464
|
|
- APP.settings.getDisplayName()
|
|
465
|
|
- );
|
|
466
|
|
- });
|
|
467
|
|
-
|
|
468
|
|
- // call hangup
|
|
469
|
|
- APP.UI.addListener(UIEvents.HANGUP, function () {
|
|
470
|
|
- APP.UI.requestFeedback().then(function () {
|
|
471
|
|
- connection.disconnect();
|
|
472
|
|
-
|
|
473
|
|
- if (config.enableWelcomePage) {
|
|
474
|
|
- setTimeout(function() {
|
|
475
|
|
- window.localStorage.welcomePageDisabled = false;
|
|
476
|
|
- window.location.pathname = "/";
|
|
477
|
|
- }, 3000);
|
|
478
|
|
- }
|
|
479
|
|
- }, function (err) {
|
|
480
|
|
- console.error(err);
|
|
481
|
|
- });
|
|
482
|
|
- });
|
|
483
|
|
-
|
|
484
|
|
- // logout
|
|
485
|
|
- APP.UI.addListener(UIEvents.LOGOUT, function () {
|
|
486
|
|
- // FIXME handle logout
|
|
487
|
|
- // APP.xmpp.logout(function (url) {
|
|
488
|
|
- // if (url) {
|
|
489
|
|
- // window.location.href = url;
|
|
490
|
|
- // } else {
|
|
491
|
|
- // hangup();
|
|
492
|
|
- // }
|
|
493
|
|
- // });
|
|
494
|
|
- });
|
|
495
|
|
-
|
|
496
|
|
- APP.UI.addListener(UIEvents.SIP_DIAL, function (sipNumber) {
|
|
497
|
|
- room.dial(sipNumber);
|
|
498
|
|
- });
|
|
499
|
|
-
|
|
500
|
|
-
|
|
501
|
|
- // Starts or stops the recording for the conference.
|
|
502
|
|
- APP.UI.addListener(UIEvents.RECORDING_TOGGLE, function (predefinedToken) {
|
|
503
|
|
- if (predefinedToken) {
|
|
504
|
|
- room.toggleRecording({token: predefinedToken});
|
|
505
|
|
- return;
|
|
506
|
|
- }
|
|
507
|
|
- APP.UI.requestRecordingToken().then((token) => {
|
|
508
|
|
- room.toggleRecording({token: token});
|
|
509
|
|
- });
|
|
510
|
|
-
|
|
511
|
|
- });
|
|
512
|
|
-
|
|
513
|
|
- APP.UI.addListener(UIEvents.TOPIC_CHANGED, function (topic) {
|
|
514
|
|
- // FIXME handle topic change
|
|
515
|
|
- // APP.xmpp.setSubject(topic);
|
|
516
|
|
- // on SUBJECT_CHANGED UI.setSubject(topic);
|
|
517
|
|
- });
|
|
518
|
|
-
|
|
519
|
|
- APP.UI.addListener(UIEvents.USER_KICKED, function (id) {
|
|
520
|
|
- room.kickParticipant(id);
|
|
521
|
|
- });
|
|
522
|
|
-
|
|
523
|
|
- APP.UI.addListener(UIEvents.REMOTE_AUDIO_MUTED, function (id) {
|
|
524
|
|
- room.muteParticipant(id);
|
|
525
|
|
- });
|
|
526
|
|
-
|
|
527
|
|
- room.on(ConferenceEvents.KICKED, function () {
|
|
528
|
|
- APP.UI.notifyKicked();
|
|
529
|
|
- // FIXME close
|
|
530
|
|
- });
|
|
531
|
|
-
|
|
532
|
|
- APP.UI.addListener(UIEvents.AUTH_CLICKED, function () {
|
|
533
|
|
- AuthHandler.authenticate(room);
|
|
534
|
|
- });
|
|
535
|
|
-
|
|
536
|
|
- APP.UI.addListener(UIEvents.SELECTED_ENDPOINT, function (id) {
|
|
537
|
|
- room.selectParticipant(id);
|
|
538
|
|
- });
|
|
539
|
|
-
|
|
540
|
|
- room.on(ConferenceEvents.DTMF_SUPPORT_CHANGED, function (isDTMFSupported) {
|
|
541
|
|
- APP.UI.updateDTMFSupport(isDTMFSupported);
|
|
542
|
|
- });
|
|
543
|
|
-
|
|
544
|
|
- APP.UI.addListener(UIEvents.TOGGLE_SCREENSHARING, function () {
|
|
545
|
|
- APP.desktopsharing.toggleScreenSharing();
|
|
546
|
|
- });
|
|
547
|
|
- APP.UI.addListener(DSEvents.SWITCHING_DONE, function (isSharingScreen) {
|
|
548
|
|
- APP.UI.updateDesktopSharingButtons(isSharingScreen);
|
|
549
|
|
- });
|
|
550
|
|
- APP.desktopsharing.addListener(
|
|
551
|
|
- DSEvents.NEW_STREAM_CREATED,
|
|
552
|
|
- (track, callback) => {
|
|
553
|
|
- const localCallback = (newTrack) => {
|
|
554
|
|
- if (newTrack.isLocal() && newTrack === localVideo) {
|
|
555
|
|
- if(localVideo.isMuted() &&
|
|
556
|
|
- localVideo.videoType !== track.videoType) {
|
|
557
|
|
- localVideo.mute();
|
|
558
|
|
- }
|
|
559
|
|
- callback();
|
|
560
|
|
- room.off(ConferenceEvents.TRACK_ADDED, localCallback);
|
|
561
|
|
- }
|
|
562
|
|
- };
|
|
563
|
|
-
|
|
564
|
|
- room.on(ConferenceEvents.TRACK_ADDED, localCallback);
|
|
565
|
|
-
|
|
566
|
|
- localVideo.stop();
|
|
567
|
|
- localVideo = track;
|
|
568
|
|
- addTrack(track);
|
|
569
|
|
- APP.UI.addLocalStream(track);
|
|
570
|
|
- }
|
|
571
|
|
- );
|
|
572
|
|
-
|
|
573
|
|
- const unload = () => {
|
|
574
|
|
- room.leave();
|
|
575
|
|
- connection.disconnect();
|
|
576
|
|
- };
|
|
577
|
|
- $(window).bind('beforeunload', unload );
|
|
578
|
|
- $(window).bind('unload', unload );
|
|
579
|
|
-
|
|
580
|
|
- return new Promise(function (resolve, reject) {
|
|
581
|
|
- room.on(ConferenceEvents.CONFERENCE_JOINED, handleConferenceJoined);
|
|
582
|
|
- room.on(ConferenceEvents.CONFERENCE_FAILED, onConferenceFailed);
|
|
583
|
|
-
|
|
584
|
|
- let password;
|
|
585
|
|
- let reconnectTimeout;
|
|
586
|
|
-
|
|
587
|
|
- function unsubscribe() {
|
|
588
|
|
- room.off(
|
|
589
|
|
- ConferenceEvents.CONFERENCE_JOINED, handleConferenceJoined
|
|
590
|
|
- );
|
|
591
|
|
- room.off(
|
|
592
|
|
- ConferenceEvents.CONFERENCE_FAILED, onConferenceFailed
|
|
593
|
|
- );
|
|
594
|
|
- if (reconnectTimeout) {
|
|
595
|
|
- clearTimeout(reconnectTimeout);
|
|
596
|
|
- }
|
|
597
|
|
- AuthHandler.closeAuth();
|
|
598
|
|
- }
|
|
599
|
|
-
|
|
600
|
|
- function handleConferenceJoined() {
|
|
601
|
|
- unsubscribe();
|
|
602
|
|
- resolve();
|
|
603
|
|
- }
|
|
604
|
|
-
|
|
605
|
|
- function handleConferenceFailed(err) {
|
|
606
|
|
- unsubscribe();
|
|
607
|
|
- reject(err);
|
|
608
|
|
- }
|
|
609
|
|
-
|
|
610
|
|
- function onConferenceFailed(err, msg = '') {
|
|
611
|
|
- console.error('CONFERENCE FAILED:', err, msg);
|
|
612
|
|
- switch (err) {
|
|
613
|
|
- // room is locked by the password
|
|
614
|
|
- case ConferenceErrors.PASSWORD_REQUIRED:
|
|
615
|
|
- APP.UI.markRoomLocked(true);
|
|
616
|
|
- roomLocker.requirePassword().then(function () {
|
|
617
|
|
- room.join(roomLocker.password);
|
|
618
|
|
- });
|
|
619
|
|
- break;
|
|
620
|
|
-
|
|
621
|
|
- case ConferenceErrors.CONNECTION_ERROR:
|
|
622
|
|
- APP.UI.notifyConnectionFailed(msg);
|
|
623
|
|
- break;
|
|
624
|
|
-
|
|
625
|
|
- // not enough rights to create conference
|
|
626
|
|
- case ConferenceErrors.AUTHENTICATION_REQUIRED:
|
|
627
|
|
- // schedule reconnect to check if someone else created the room
|
|
628
|
|
- reconnectTimeout = setTimeout(function () {
|
|
629
|
|
- room.join(password);
|
|
630
|
|
- }, 5000);
|
|
631
|
|
-
|
|
632
|
|
- // notify user that auth is required
|
|
633
|
|
- AuthHandler.requireAuth(APP.conference.roomName);
|
|
634
|
|
- break;
|
|
635
|
|
-
|
|
636
|
|
- default:
|
|
637
|
|
- handleConferenceFailed(err);
|
|
638
|
|
- }
|
|
639
|
|
- }
|
|
640
|
|
-
|
|
641
|
|
- room.join(password);
|
|
642
|
|
- });
|
|
643
|
|
-}
|
|
644
|
|
-
|
|
645
|
|
-function connect() {
|
|
646
|
|
- return openConnection({retry: true}).catch(function (err) {
|
|
647
|
|
- if (err === ConnectionErrors.PASSWORD_REQUIRED) {
|
|
648
|
|
- APP.UI.notifyTokenAuthFailed();
|
|
649
|
|
- } else {
|
|
650
|
|
- APP.UI.notifyConnectionFailed(err);
|
|
651
|
|
- }
|
|
652
|
|
- throw err;
|
|
653
|
|
- });
|
|
654
|
|
-}
|
|
655
|
|
-
|
|
656
|
78
|
function init() {
|
|
657
|
79
|
APP.UI.start();
|
|
658
|
|
-
|
|
659
|
|
- JitsiMeetJS.setLogLevel(JitsiMeetJS.logLevels.TRACE);
|
|
660
|
|
-
|
|
661
|
|
- JitsiMeetJS.init(config).then(function () {
|
|
662
|
|
- return Promise.all([
|
|
663
|
|
- APP.createLocalTracks('audio', 'video'),
|
|
664
|
|
- connect()
|
|
665
|
|
- ]);
|
|
666
|
|
- }).then(function ([tracks, connection]) {
|
|
667
|
|
- console.log('initialized with %s local tracks', tracks.length);
|
|
668
|
|
- return initConference(tracks, connection);
|
|
669
|
|
- }).then(function () {
|
|
|
80
|
+ APP.conference.init({roomName: buildRoomName()}).then(function () {
|
|
670
|
81
|
APP.UI.initConference();
|
|
671
|
82
|
|
|
672
|
83
|
APP.UI.addListener(UIEvents.LANG_CHANGED, function (language) {
|