2020-03-03 04:51:51 +08:00
|
|
|
import Users from '/imports/api/users';
|
2020-03-03 05:41:31 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2020-03-03 04:51:51 +08:00
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
|
|
|
|
|
|
|
export default function emitExternalVideoEvent(messageName, ...rest) {
|
2020-03-04 06:00:38 +08:00
|
|
|
const { meetingId, requesterUserId: userId } = extractCredentials(this.userId);
|
2020-03-03 04:51:51 +08:00
|
|
|
|
2020-03-04 06:00:38 +08:00
|
|
|
const user = Users.findOne({ userId, meetingId });
|
2020-03-03 04:51:51 +08:00
|
|
|
|
|
|
|
if (user && user.presenter) {
|
|
|
|
const streamerName = `external-videos-${meetingId}`;
|
|
|
|
const streamer = Meteor.StreamerCentral.instances[streamerName];
|
|
|
|
|
|
|
|
if (streamer) {
|
2020-03-04 06:00:38 +08:00
|
|
|
streamer.emit(messageName, ...rest);
|
2020-03-03 04:51:51 +08:00
|
|
|
} else {
|
2020-03-04 00:21:08 +08:00
|
|
|
Logger.error(`External Video Streamer not found for meetingId: ${meetingId} userId: ${userId}`);
|
2020-03-03 04:51:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|