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

26 lines
762 B
JavaScript
Raw Normal View History

2019-10-25 04:48:03 +08:00
import publishCursorUpdate from './methods/publishCursorUpdate';
export function removeCursorStreamer(meetingId) {
delete Meteor.StreamerCentral.instances[`cursor-${meetingId}`];
}
export function addCursorStreamer(meetingId) {
const streamer = new Meteor.Streamer(`cursor-${meetingId}`, { retransmit: false });
streamer.allowRead(function allowRead() {
return this.userId && this.userId.includes(meetingId);
});
streamer.allowWrite(function allowWrite() {
return this.userId && this.userId.includes(meetingId);
});
streamer.on('publish', (message) => {
publishCursorUpdate(message.credentials, message.payload);
});
}
export default function get(meetingId) {
return Meteor.StreamerCentral.instances[`cursor-${meetingId}`];
}