use JitsiParticipant to handle user roles

This commit is contained in:
isymchych
2015-12-08 17:13:44 +02:00
parent 0460e7da29
commit fbcd2d2320
3 changed files with 1528 additions and 946 deletions

29
app.js
View File

@@ -161,12 +161,10 @@ function initConference(localTracks, connection) {
disableAudioLevels: config.disableAudioLevels
});
var users = {};
APP.conference.localId = room.myUserId();
Object.defineProperty(APP.conference, "membersCount", {
get: function () {
return Object.keys(users).length; // FIXME maybe +1?
return room.getParticipants().length; // FIXME maybe +1?
}
});
@@ -175,9 +173,9 @@ function initConference(localTracks, connection) {
return APP.settings.getDisplayName();
}
var user = users[id];
if (user && user.displayName) {
return user.displayName;
var participant = room.getParticipantById(id);
if (participant && participant.getDisplayName()) {
return participant.getDisplayName();
}
}
@@ -191,19 +189,28 @@ function initConference(localTracks, connection) {
room.on(ConferenceEvents.USER_JOINED, function (id) {
users[id] = {
displayName: undefined,
tracks: []
};
// FIXME email???
APP.UI.addUser(id);
});
room.on(ConferenceEvents.USER_LEFT, function (id) {
delete users[id];
APP.UI.removeUser(id);
});
room.on(ConferenceEvents.USER_ROLE_CHANGED, function (id, role) {
if (APP.conference.isLocalId(id)) {
console.info(`My role changed, new role: ${role}`);
APP.conference.isModerator = room.isModerator();
APP.UI.updateLocalRole(room.isModerator());
} else {
var user = room.getParticipantById(id);
if (user) {
APP.UI.updateUserRole(user);
}
}
});
room.on(ConferenceEvents.TRACK_MUTE_CHANGED, function (track) {
// FIXME handle mute
});