bigbluebutton-Github/bigbluebutton-html5/imports/api/phone/server/eventHandlers.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-05-17 03:12:49 +08:00
import { eventEmitter } from '/imports/startup/server';
import { updateVoiceUser } from '/imports/api/users/server/modifiers/updateVoiceUser';
eventEmitter.on('user_left_voice_message', function (arg) {
handleVoiceEvent(arg);
});
eventEmitter.on('user_joined_voice_message', function (arg) {
handleVoiceEvent(arg);
});
eventEmitter.on('user_voice_talking_message', function (arg) {
handleVoiceEvent(arg);
});
eventEmitter.on('user_voice_muted_message', function (arg) {
handleVoiceEvent(arg);
});
eventEmitter.on('user_listening_only', function (arg) {
const voiceUserObj = {
web_userid: arg.payload.userid,
listen_only: arg.payload.listen_only,
};
const meetingId = arg.payload.meeting_id;
return updateVoiceUser(meetingId, voiceUserObj, arg.callback);
});
const handleVoiceEvent = function (arg) {
const meetingId = arg.payload.meeting_id;
const voiceUser = payload.user.voiceUser;
const voiceUserObj = {
web_userid: voiceUser.web_userid,
listen_only: arg.payload.listen_only,
talking: voiceUser.talking,
joined: voiceUser.joined,
locked: voiceUser.locked,
muted: voiceUser.muted,
};
return updateVoiceUser(meetingId, voiceUserObj, arg.callback);
};