bigbluebutton-Github/bigbluebutton-html5/imports/api/cursor/index.js
Oswaldo Acauan ec07b4434d Change cursor and annotation to user streams and add optimistic updates
WIP | Use streams to cursor and optimistic updates

WIP | Use streamss to whiteboard and optimistic updates

WIP | Remove fake delay

Add two way batching (server/client client/server)

Fix null userId exception and remove logs

wip

Add two way batching (server/client client/server) for cursor

Remove message frequency from draw-listeners component since we handle on message publication

Handle clear and undo messages
2018-05-28 14:46:14 -03:00

43 lines
1.1 KiB
JavaScript
Executable File

import { Meteor } from 'meteor/meteor';
import Users from '/imports/api/users';
const Cursor = new Mongo.Collection('cursor');
const Streamer = new Meteor.Streamer('cursor', { retransmit: false, });
if (Meteor.isServer) {
import publishCursorUpdate from './server/methods/publishCursorUpdate';
Streamer.on('publish', (message) => {
publishCursorUpdate(message.credentials, message.payload);
});
Streamer.allowRead(function(eventName, ...args) {
return true;
});
Streamer.allowEmit(function(eventName, { meetingId }) {
return this.userId && this.userId.includes(meetingId);
});
Streamer.allowWrite(function(eventName, { credentials }) {
if (!this.userId || !credentials) return false;
const { meetingId, requesterUserId: userId, requesterToken: authToken } = credentials;
const user = Users.findOne({
meetingId,
userId,
authToken,
connectionId: this.connection.id,
validated: true,
connectionStatus: 'online',
});
if (!user) return false;
return true;
});
}
export default Cursor;
export const CursorStreamer = Streamer;