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

36 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-11-14 00:53:45 +08:00
import Logger from '/imports/startup/server/logger';
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);
});
streamer.on('publish', (message) => {
publishCursorUpdate(meetingId, message.userId, message.payload);
2019-10-25 04:48:03 +08:00
});
}
export default function get(meetingId) {
return Meteor.StreamerCentral.instances[`cursor-${meetingId}`];
}