-
Notifications
You must be signed in to change notification settings - Fork 5.9k
/
Conference.as
601 lines (516 loc) · 15.9 KB
/
Conference.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 3.0 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
*/
package org.bigbluebutton.main.model.users {
import mx.collections.ArrayCollection;
import mx.collections.Sort;
import org.as3commons.logging.api.ILogger;
import org.as3commons.logging.api.getClassLogger;
import org.bigbluebutton.common.Role;
import org.bigbluebutton.core.BBB;
import org.bigbluebutton.core.model.Config;
import org.bigbluebutton.core.vo.CameraSettingsVO;
import org.bigbluebutton.core.vo.LockSettingsVO;
public class Conference {
public var userEjectedFromMeeting:Boolean = false;
public var meetingName:String;
public var externalMeetingID:String;
public var internalMeetingID:String;
public var externalUserID:String;
public var avatarURL:String;
public var voiceBridge:String;
public var dialNumber:String;
public var isBreakout:Boolean;
[Bindable]
public var record:Boolean;
private static const LOGGER:ILogger = getClassLogger(Conference);
private var lockSettings:LockSettingsVO;
private var _myCamSettings:CameraSettingsVO = new CameraSettingsVO();
[Bindable]
private var me:BBBUser = null;
[Bindable]
public var users:ArrayCollection = null;
[Bindable]
public var breakoutRooms:ArrayCollection = null;
private var sort:Sort;
private var defaultLayout:String;
public function Conference():void {
me = new BBBUser();
users = new ArrayCollection();
sort = new Sort();
sort.compareFunction = sortFunction;
users.sort = sort;
users.refresh();
breakoutRooms = new ArrayCollection();
}
// Custom sort function for the users ArrayCollection. Need to put dial-in users at the very bottom.
private function sortFunction(a:Object, b:Object, array:Array = null):int {
/*if (a.presenter)
return -1;
else if (b.presenter)
return 1;*/
if (a.role == Role.MODERATOR && b.role == Role.MODERATOR) {
if (a.hasEmojiStatus && b.hasEmojiStatus) {
if (a.emojiStatusTime < b.emojiStatusTime)
return -1;
else
return 1;
} else if (a.hasEmojiStatus)
return -1;
else if (b.hasEmojiStatus)
return 1;
} else if (a.role == Role.MODERATOR)
return -1;
else if (b.role == Role.MODERATOR)
return 1;
else if (a.hasEmojiStatus && b.hasEmojiStatus) {
if (a.emojiStatusTime < b.emojiStatusTime)
return -1;
else
return 1;
} else if (a.hasEmojiStatus)
return -1;
else if (b.hasEmojiStatus)
return 1;
else if (!a.phoneUser && !b.phoneUser) {
} else if (!a.phoneUser)
return -1;
else if (!b.phoneUser)
return 1;
/*
* Check name (case-insensitive) in the event of a tie up above. If the name
* is the same then use userID which should be unique making the order the same
* across all clients.
*/
if (a.name.toLowerCase() < b.name.toLowerCase())
return -1;
else if (a.name.toLowerCase() > b.name.toLowerCase())
return 1;
else if (a.userID.toLowerCase() > b.userID.toLowerCase())
return -1;
else if (a.userID.toLowerCase() < b.userID.toLowerCase())
return 1;
return 0;
}
public function addUser(newuser:BBBUser):void {
if (hasUser(newuser.userID)) {
removeUser(newuser.userID);
}
if (newuser.userID == me.userID) {
newuser.me = true;
}
users.addItem(newuser);
users.refresh();
}
public function setCamPublishing(publishing:Boolean):void {
_myCamSettings.isPublishing = publishing;
}
public function setCameraSettings(camSettings:CameraSettingsVO):void {
_myCamSettings = camSettings;
}
public function amIPublishing():CameraSettingsVO {
return _myCamSettings;
}
public function setDefaultLayout(defaultLayout:String):void {
this.defaultLayout = defaultLayout;
}
public function getDefaultLayout():String {
return defaultLayout;
}
public function hasUser(userID:String):Boolean {
var p:Object = getUserIndex(userID);
if (p != null) {
return true;
}
return false;
}
public function hasOnlyOneModerator():Boolean {
var p:BBBUser;
var moderatorCount:int = 0;
for (var i:int = 0; i < users.length; i++) {
p = users.getItemAt(i) as BBBUser;
if (p.role == Role.MODERATOR) {
moderatorCount++;
}
}
if (moderatorCount == 1)
return true;
return false;
}
public function getTheOnlyModerator():BBBUser {
var p:BBBUser;
for (var i:int = 0; i < users.length; i++) {
p = users.getItemAt(i) as BBBUser;
if (p.role == Role.MODERATOR) {
return BBBUser.copy(p);
}
}
return null;
}
public function getPresenter():BBBUser {
var p:BBBUser;
for (var i:int = 0; i < users.length; i++) {
p = users.getItemAt(i) as BBBUser;
if (isUserPresenter(p.userID)) {
return BBBUser.copy(p);
}
}
return null;
}
public function getUser(userID:String):BBBUser {
var p:Object = getUserIndex(userID);
if (p != null) {
return p.participant as BBBUser;
}
return null;
}
public function getUserWithExternUserID(userID:String):BBBUser {
var p:BBBUser;
for (var i:int = 0; i < users.length; i++) {
p = users.getItemAt(i) as BBBUser;
if (p.externUserID == userID) {
return BBBUser.copy(p);
}
}
return null;
}
public function isUserPresenter(userID:String):Boolean {
var user:Object = getUserIndex(userID);
if (user == null) {
return false;
}
var a:BBBUser = user.participant as BBBUser;
return a.presenter;
}
public function removeUser(userID:String):void {
var p:Object = getUserIndex(userID);
if (p != null) {
users.removeItemAt(p.index);
//sort();
users.refresh();
}
}
/**
* Get the index number of the participant with the specific userid
* @param userid
* @return -1 if participant not found
*
*/
private function getUserIndex(userID:String):Object {
var aUser:BBBUser;
for (var i:int = 0; i < users.length; i++) {
aUser = users.getItemAt(i) as BBBUser;
if (aUser.userID == userID) {
return {index: i, participant: aUser};
}
}
// Participant not found.
return null;
}
public function whatsMyRole():String {
return me.role;
}
[Bindable]
public function get amIPresenter():Boolean {
return me.presenter;
}
public function set amIPresenter(presenter:Boolean):void {
me.presenter = presenter;
}
[Bindable]
public function get myEmojiStatus():String {
return me.emojiStatus;
}
public function set myEmojiStatus(emoji:String):void {
me.emojiStatus = emoji;
}
public function amIThisUser(userID:String):Boolean {
return me.userID == userID;
}
public function getMyRole():String {
return me.role;
}
public function amIModerator():Boolean {
return me.role == Role.MODERATOR;
}
public function muteMyVoice(mute:Boolean):void {
voiceMuted = mute;
}
public function isMyVoiceMuted():Boolean {
return me.voiceMuted;
}
[Bindable]
public function set voiceMuted(m:Boolean):void {
me.voiceMuted = m;
}
public function get voiceMuted():Boolean {
return me.voiceMuted;
}
public function setMyVoiceJoined(joined:Boolean):void {
voiceJoined = joined;
}
public function amIVoiceJoined():Boolean {
return me.voiceJoined;
}
/** Hook to make the property Bindable **/
[Bindable]
public function set voiceJoined(j:Boolean):void {
me.voiceJoined = j;
}
public function get voiceJoined():Boolean {
return me.voiceJoined;
}
[Bindable]
public function set locked(locked:Boolean):void {
me.userLocked = locked;
}
public function get locked():Boolean {
return me.userLocked;
}
public function setUserEjectedFromMeeting():void {
userEjectedFromMeeting = true;
}
public function getUserEjectedFromMeeting():Boolean {
return userEjectedFromMeeting;
}
public function getMyExternalUserID():String {
return externalUserID;
}
public function getMyUserId():String {
return me.userID;
}
public function setMyUserid(userID:String):void {
me.userID = userID;
}
public function setMyName(name:String):void {
me.name = name;
}
public function getMyName():String {
return me.name;
}
public function setMyCustomData(customdata:Object):void {
me.customdata = customdata;
}
public function getMyCustomData():Object {
return me.customdata;
}
public function setMyRole(role:String):void {
me.role = role;
}
public function setMyRoom(room:String):void {
me.room = room;
}
public function setMyAuthToken(token:String):void {
me.authToken = token;
}
public function removeAllParticipants():void {
//users.removeAll();
//users.refresh();
for (var i:int = 0; i < users.length; i++) {
users.removeItemAt(i);
//sort();
users.refresh();
}
}
public function emojiStatus(userId:String, emoji:String):void {
var aUser:BBBUser = getUser(userId);
if (aUser != null) {
aUser.userEmojiStatus(emoji)
}
users.refresh();
}
public function sharedWebcam(userId:String, stream:String):void {
var aUser:BBBUser = getUser(userId);
if (aUser != null) {
aUser.sharedWebcam(stream)
}
users.refresh();
}
public function unsharedWebcam(userId:String, stream:String):void {
var aUser:BBBUser = getUser(userId);
if (aUser != null) {
aUser.unsharedWebcam(stream);
}
users.refresh();
}
public function presenterStatusChanged(userId:String, presenter:Boolean):void {
var aUser:BBBUser = getUser(userId);
if (aUser != null) {
aUser.presenterStatusChanged(presenter)
}
users.refresh();
}
public function newUserStatus(userID:String, status:String, value:Object):void {
var aUser:BBBUser = getUser(userID);
if (aUser != null) {
var s:Status = new Status(status, value);
aUser.changeStatus(s);
}
users.refresh();
}
public function getUserIDs():ArrayCollection {
var uids:ArrayCollection = new ArrayCollection();
for (var i:int = 0; i < users.length; i++) {
var u:BBBUser = users.getItemAt(i) as BBBUser;
uids.addItem(u.userID);
}
return uids;
}
/**
* Read default lock settings from config.xml
* */
public function configLockSettings():void {
var config:Config = BBB.getConfigManager().config;
var disableCam:Boolean,
disableMic:Boolean,
disablePrivateChat:Boolean,
disablePublicChat:Boolean,
lockedLayout:Boolean,
lockOnJoin:Boolean,
lockOnJoinConfigurable:Boolean;
var lockConfig:XML;
if (config != null) {
lockConfig = config.lock;
}
try {
disableCam = (lockConfig.@disableCamForLockedUsers.toUpperCase() == "TRUE");
} catch (e:Error) {
disableCam = false; //If not set, default to false
}
try {
disableMic = (lockConfig.@disableMicForLockedUsers.toUpperCase() == "TRUE");
} catch (e:Error) {
disableMic = false; //If not set, default to false
}
try {
disablePrivateChat = (lockConfig.@disablePrivateChatForLockedUsers.toUpperCase() == "TRUE");
} catch (e:Error) {
disablePrivateChat = false; //If not set, default to false
}
try {
disablePublicChat = (lockConfig.@disablePublicChatForLockedUsers.toUpperCase() == "TRUE");
} catch (e:Error) {
disablePublicChat = false; //If not set, default to false
}
try {
lockedLayout = (lockConfig.@lockLayoutForLockedUsers.toUpperCase() == "TRUE");
} catch (e:Error) {
lockedLayout = false; //If not set, default to false
}
try {
lockOnJoin = (lockConfig.@lockOnJoin.toUpperCase() == "TRUE");
} catch (e:Error) {
lockOnJoin = true; //If not set, default to true
}
try {
lockOnJoinConfigurable = (lockConfig.@lockOnJoinConfigurable.toUpperCase() == "TRUE");
} catch (e:Error) {
lockOnJoinConfigurable = false; //If not set, default to false
}
lockSettings = new LockSettingsVO(disableCam, disableMic, disablePrivateChat, disablePublicChat, lockedLayout, lockOnJoin, lockOnJoinConfigurable);
setLockSettings(lockSettings);
}
public function getMyUser():BBBUser {
var eachUser:BBBUser;
for (var i:int = 0; i < users.length; i++) {
eachUser = users.getItemAt(i) as BBBUser;
if (eachUser.userID == me.userID) {
return eachUser;
}
}
return null;
}
public function getLockSettings():LockSettingsVO {
return lockSettings;
}
public function setLockSettings(lockSettings:LockSettingsVO):void {
this.lockSettings = lockSettings;
applyLockSettings();
users.refresh(); // we need to refresh after updating the lock settings to trigger the user item renderers to redraw
}
public function applyLockSettings():void {
var myUser:BBBUser = getMyUser();
if (myUser != null)
myUser.applyLockSettings();
}
/* Breakout room feature */
public function addBreakoutRoom(newRoom:BreakoutRoom):void {
if (hasBreakoutRoom(newRoom.breakoutId)) {
removeBreakoutRoom(newRoom.breakoutId);
}
breakoutRooms.addItem(newRoom);
breakoutRooms.refresh();
}
public function updateBreakoutRoomUsers(breakoutId:String, users:int):void {
var room:Object = getBreakoutRoom(breakoutId);
if (room != null) {
BreakoutRoom(room).numberOfUsers = users;
}
}
/**
* Returns a breakout room by its breakoutId
*/
public function getBreakoutRoom(breakoutId:String):BreakoutRoom {
var r:Object = getBreakoutRoomIndex(breakoutId);
if (r != null) {
return r.room as BreakoutRoom;
}
return null;
}
/**
* Finds the index of a breakout room by its breakoutId
*/
public function getBreakoutRoomIndex(breakoutId:String):Object {
var aRoom:BreakoutRoom;
for (var i:int = 0; i < breakoutRooms.length; i++) {
aRoom = breakoutRooms.getItemAt(i) as BreakoutRoom;
if (aRoom.breakoutId == breakoutId) {
return {index: i, room: aRoom};
}
}
// Breakout room not found.
return null;
}
public function removeBreakoutRoom(breakoutId:String):void {
var p:Object = getBreakoutRoomIndex(breakoutId);
if (p != null) {
breakoutRooms.removeItemAt(p.index);
breakoutRooms.refresh();
}
}
public function hasBreakoutRoom(breakoutId:String):Boolean {
var p:Object = getBreakoutRoomIndex(breakoutId);
if (p != null) {
return true;
}
return false;
}
public function setBreakoutRoomInListen(listen:Boolean, breakoutId:String):void {
for (var i:int = 0; i < breakoutRooms.length; i++) {
var br:BreakoutRoom = BreakoutRoom(breakoutRooms.getItemAt(i));
if (listen == false) {
br.listenStatus = BreakoutRoom.NONE;
} else if (listen == true && br.breakoutId == breakoutId) {
br.listenStatus = BreakoutRoom.SELF;
} else {
br.listenStatus = BreakoutRoom.OTHER;
}
}
}
}
}