2020-08-28 18:58:55 +08:00
|
|
|
import { check } from 'meteor/check';
|
2020-03-03 05:41:31 +08:00
|
|
|
import Logger from '/imports/startup/server/logger';
|
2020-08-28 18:58:55 +08:00
|
|
|
import RedisPubSub from '/imports/startup/server/redis';
|
2020-03-03 04:51:51 +08:00
|
|
|
import { extractCredentials } from '/imports/api/common/server/helpers';
|
|
|
|
|
2020-08-28 18:58:55 +08:00
|
|
|
export default function emitExternalVideoEvent(options) {
|
|
|
|
const REDIS_CONFIG = Meteor.settings.private.redis;
|
|
|
|
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
|
|
|
|
const EVENT_NAME = 'UpdateExternalVideoPubMsg';
|
|
|
|
|
2021-05-05 03:33:29 +08:00
|
|
|
try {
|
|
|
|
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
|
|
|
|
|
|
|
check(meetingId, String);
|
|
|
|
check(requesterUserId, String);
|
|
|
|
|
|
|
|
const { status, playerStatus } = options;
|
|
|
|
|
2021-05-28 07:50:43 +08:00
|
|
|
check(status, String);
|
|
|
|
check(playerStatus, {
|
|
|
|
rate: Match.Maybe(Number),
|
|
|
|
time: Match.Maybe(Number),
|
|
|
|
state: Match.Maybe(Number),
|
|
|
|
});
|
|
|
|
|
2021-06-01 06:42:39 +08:00
|
|
|
const state = playerStatus.state || 0;
|
|
|
|
|
2021-05-28 07:50:43 +08:00
|
|
|
const payload = {
|
|
|
|
status,
|
|
|
|
rate: playerStatus.rate || 0,
|
|
|
|
time: playerStatus.time || 0,
|
2021-06-01 06:42:39 +08:00
|
|
|
state,
|
2021-05-28 07:50:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
Logger.debug(`User id=${requesterUserId} sending ${EVENT_NAME} event:${state} for meeting ${meetingId}`);
|
|
|
|
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
2021-05-05 03:33:29 +08:00
|
|
|
} catch (err) {
|
|
|
|
Logger.error(`Exception while invoking method emitExternalVideoEvent ${err.stack}`);
|
2021-02-26 03:54:22 +08:00
|
|
|
}
|
2020-03-03 04:51:51 +08:00
|
|
|
}
|