bigbluebutton-Github/bigbluebutton-html5/imports/api/cursor/server/streamer.js

38 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-11-14 00:53:45 +08:00
import Logger from '/imports/startup/server/logger';
2021-04-14 01:36:46 +08:00
import { extractCredentials } from '/imports/api/common/server/helpers';
2019-10-25 04:48:03 +08:00
import publishCursorUpdate from './methods/publishCursorUpdate';
const { streamerLog } = Meteor.settings.private.serverLog;
2019-10-25 04:48:03 +08:00
export function removeCursorStreamer(meetingId) {
2019-11-14 00:53:45 +08:00
Logger.info(`Removing Cursor streamer object for meeting ${meetingId}`);
2019-10-25 04:48:03 +08:00
delete Meteor.StreamerCentral.instances[`cursor-${meetingId}`];
}
export function addCursorStreamer(meetingId) {
const streamer = new Meteor.Streamer(`cursor-${meetingId}`, { retransmit: false });
if (streamerLog) {
Logger.debug('Cursor streamer created', { meetingId });
}
2019-12-04 23:42:41 +08:00
2019-10-25 04:48:03 +08:00
streamer.allowRead(function allowRead() {
if (streamerLog) {
Logger.debug('Cursor streamer called allowRead', { userId: this.userId, meetingId });
}
2019-10-25 04:48:03 +08:00
return this.userId && this.userId.includes(meetingId);
});
streamer.allowWrite(function allowWrite() {
return this.userId && this.userId.includes(meetingId);
});
2021-04-14 01:36:46 +08:00
streamer.on('publish', function (message) {
const { requesterUserId } = extractCredentials(this.userId);
publishCursorUpdate(meetingId, requesterUserId, message);
2019-10-25 04:48:03 +08:00
});
}
export default function get(meetingId) {
return Meteor.StreamerCentral.instances[`cursor-${meetingId}`];
}