- create users state classes

This commit is contained in:
Richard Alam 2017-06-13 14:54:11 -07:00
parent b677b4490f
commit 2c4fe3f3b8
5 changed files with 178 additions and 144 deletions

View File

@ -0,0 +1,17 @@
package org.bigbluebutton.core.model.users
{
public class User2x {
var intId: String;
var extId: String;
var name: String;
var role: String;
var guest: Boolean;
var authed: Boolean;
var waitingForAcceptance: Boolean;
var emoji: String;
var locked: Boolean;
var presenter: Boolean;
var avatar: String;
}
}

View File

@ -1,130 +0,0 @@
package org.bigbluebutton.core.model.users
{
import mx.collections.ArrayCollection;
import org.bigbluebutton.core.model.Me;
import org.bigbluebutton.core.vo.UserVO;
import org.bigbluebutton.core.vo.VoiceUserVO;
public class Users
{
private var _users:ArrayCollection = new ArrayCollection();
private function add(user: UserVO):void {
_users.addItem(user);
}
private function remove(userId: String):UserVO {
var index:int = getIndex(userId);
if (index >= 0) {
return _users.removeItemAt(index) as UserVO;
}
return null;
}
private function getUserAndIndex(userId: String):Object {
var user:User;
for (var i:int = 0; i < _users.length; i++) {
user = _users.getItemAt(i) as User;
if (user.id == userId) {
return {index:i, user:user};;
}
}
return null;
}
private function getUser(userId:String):UserVO {
var user:UserVO;
for (var i:int = 0; i < _users.length; i++) {
user = _users.getItemAt(i) as UserVO;
if (user.id == userId) {
return user;
}
}
return null;
}
private function getIndex(userId: String):int {
var user:UserVO;
for (var i:int = 0; i < _users.length; i++) {
user = _users.getItemAt(i) as UserVO;
if (user.id == userId) {
return i;
}
}
return -1;
}
public function userJoinedVoice(vu: VoiceUserVO):UserVO {
var user: UserVO = getUser(vu.webId) as UserVO;
if (user != null) {
user.voiceUser = vu;
return user.copy();
}
return null;
}
public function userLeftVoice(vu: VoiceUserVO):UserVO {
var user:UserVO = getUser(vu.webId) as UserVO;
if (user != null) {
user.voiceUser = vu;
return user.copy();
}
return null;
}
public function userJoined(vu: UserVO):UserVO {
add(vu);
return vu.copy();
}
public function userLeft(vu: UserVO):UserVO {
var user: UserVO = remove(vu.id);
if (user != null) {
return user.copy();
}
return null;
}
public function userMuted(userId: String, voiceId: String, muted: Boolean):UserVO {
var user: UserVO = getUser(userId) as UserVO;
if (user != null) {
user.voiceUser.muted = muted;
return user.copy();
}
return null;
}
public function userTalking(userId: String, voiceId: String, talking: Boolean):UserVO {
var user: UserVO = getUser(userId) as UserVO;
if (user != null) {
user.voiceUser.talking = talking;
return user.copy();
}
return null;
}
// private function get users():ArrayCollection {
// var us:ArrayCollection = new ArrayCollection();
// for (var i:int = 0; i < _users.length; i++) {
//
// }
// }
}
}

View File

@ -1,17 +1,75 @@
package org.bigbluebutton.core.model.users
{
import mx.collections.ArrayCollection;
import org.bigbluebutton.core.model.Me;
public class Users2x
{
private var _users:ArrayCollection = new ArrayCollection();
private function add(user: User2x):void {
_users.addItem(user);
}
private function remove(userId: String):User2x {
var index:int = getIndex(userId);
if (index >= 0) {
return _users.removeItemAt(index) as User2x;
}
return null;
}
private function getUserAndIndex(userId: String):Object {
var user:User2x;
for (var i:int = 0; i < _users.length; i++) {
user = _users.getItemAt(i) as User2x;
if (user.id == userId) {
return {index:i, user:user};;
}
}
return null;
}
private function getUser(userId:String):User2x {
var user:User2x;
for (var i:int = 0; i < _users.length; i++) {
user = _users.getItemAt(i) as User2x;
if (user.id == userId) {
return user;
}
}
return null;
}
private function getIndex(userId: String):int {
var user:User2x;
for (var i:int = 0; i < _users.length; i++) {
user = _users.getItemAt(i) as User2x;
if (user.id == userId) {
return i;
}
}
return -1;
}
public function userJoined(vu: User2x):void {
add(vu);
}
public function userLeft(intId: String):User2x {
return remove(intId);
}
}
}
public class User2x {
var intId: String;
var extId: String;
var name: String;
var role: String;
var guest: Boolean;
var authed: Boolean;
var waitingForAcceptance: Boolean;
var emoji: String;
var locked: Boolean;
var presenter: Boolean;
var avatar: String;
}
}

View File

@ -0,0 +1,14 @@
package org.bigbluebutton.core.model.users
{
public class VoiceUser2x {
var intId: String;
var voiceUserId: String;
var callingWith: String;
var callerName: String;
var callerNum: String;
var muted: Boolean;
var talking: Boolean;
var listenOnly: Boolean;
}
}

View File

@ -0,0 +1,75 @@
package org.bigbluebutton.core.model.users
{
import mx.collections.ArrayCollection;
import org.bigbluebutton.core.model.Me;
public class VoiceUsers2x
{
private var _users:ArrayCollection = new ArrayCollection();
private function add(user: VoiceUser2x):void {
_users.addItem(user);
}
private function remove(userId: String):VoiceUser2x {
var index:int = getIndex(userId);
if (index >= 0) {
return _users.removeItemAt(index) as VoiceUser2x;
}
return null;
}
private function getUserAndIndex(userId: String):Object {
var user:VoiceUser2x;
for (var i:int = 0; i < _users.length; i++) {
user = _users.getItemAt(i) as VoiceUser2x;
if (user.id == userId) {
return {index:i, user:user};;
}
}
return null;
}
private function getUser(userId:String):VoiceUser2x {
var user:VoiceUser2x;
for (var i:int = 0; i < _users.length; i++) {
user = _users.getItemAt(i) as VoiceUser2x;
if (user.id == userId) {
return user;
}
}
return null;
}
private function getIndex(userId: String):int {
var user:VoiceUser2x;
for (var i:int = 0; i < _users.length; i++) {
user = _users.getItemAt(i) as VoiceUser2x;
if (user.id == userId) {
return i;
}
}
return -1;
}
public function userJoined(vu: VoiceUser2x):void {
add(vu);
}
public function userLeft(intId: String):VoiceUser2x {
return remove(intId);
}
}
}