Refactor API Cursor's
This commit is contained in:
parent
e644576063
commit
b4f9d88fac
10
bigbluebutton-html5/.Trash-1000/files/clearCursors.js
Normal file
10
bigbluebutton-html5/.Trash-1000/files/clearCursors.js
Normal file
@ -0,0 +1,10 @@
|
||||
import Cursor from '/imports/api/cursor';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
|
||||
export default function clearCursor(meetingId) {
|
||||
if (meetingId) {
|
||||
return Cursor.remove({ meetingId }, Logger.info(`Cleared Cursor (${meetingId})`));
|
||||
} else {
|
||||
return Cursor.remove({}, Logger.info('Cleared Cursor (all)'));
|
||||
}
|
||||
};
|
@ -0,0 +1,3 @@
|
||||
[Trash Info]
|
||||
Path=imports/api/cursor/server/modifiers/clearCursors.js
|
||||
DeletionDate=2016-11-18T09:49:05
|
@ -0,0 +1,3 @@
|
||||
[Trash Info]
|
||||
Path=imports/api/cursor/server/modifiers/eventHandlers.js
|
||||
DeletionDate=2016-11-18T09:49:29
|
@ -0,0 +1,3 @@
|
||||
[Trash Info]
|
||||
Path=imports/api/cursor/server/publications.js
|
||||
DeletionDate=2016-11-18T09:46:05
|
@ -0,0 +1,4 @@
|
||||
import RedisPubSub from '/imports/startup/server/redis';
|
||||
import handleCursorUpdate from './handlers/cursorUpdate';
|
||||
|
||||
RedisPubSub.on('presentation_cursor_updated_message', handleCursorUpdate);
|
@ -0,0 +1,15 @@
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import { check } from 'meteor/check';
|
||||
import updateCursor from '../modifiers/updateCursor';
|
||||
|
||||
export default function handleCursorUpdate({ payload }) {
|
||||
const meetingId = payload.meeting_id;
|
||||
const x = payload.x_percent;
|
||||
const y = payload.y_percent;
|
||||
|
||||
check(meetingId, String);
|
||||
check(x, Number);
|
||||
check(y, Number);
|
||||
|
||||
return updateCursor(meetingId, x, y);
|
||||
};
|
3
bigbluebutton-html5/imports/api/cursor/server/index.js
Normal file
3
bigbluebutton-html5/imports/api/cursor/server/index.js
Normal file
@ -0,0 +1,3 @@
|
||||
import './eventHandlers';
|
||||
import './methods';
|
||||
import './publishers';
|
4
bigbluebutton-html5/imports/api/cursor/server/methods.js
Normal file
4
bigbluebutton-html5/imports/api/cursor/server/methods.js
Normal file
@ -0,0 +1,4 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
|
||||
Meteor.methods({
|
||||
});
|
10
bigbluebutton-html5/imports/api/cursor/server/modifiers/clearCursor.js
Executable file
10
bigbluebutton-html5/imports/api/cursor/server/modifiers/clearCursor.js
Executable file
@ -0,0 +1,10 @@
|
||||
import Cursor from '/imports/api/cursor';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
|
||||
export default function clearCursor(meetingId) {
|
||||
if (meetingId) {
|
||||
return Cursor.remove({ meetingId }, Logger.info(`Cleared Cursor (${meetingId})`));
|
||||
} else {
|
||||
return Cursor.remove({}, Logger.info('Cleared Cursor (all)'));
|
||||
}
|
||||
};
|
@ -1,14 +0,0 @@
|
||||
import Cursor from '/imports/api/cursor';
|
||||
import { logger } from '/imports/startup/server/logger';
|
||||
|
||||
// called on server start and meeting end
|
||||
export function clearCursorCollection() {
|
||||
const meetingId = arguments[0];
|
||||
if (meetingId != null) {
|
||||
return Cursor.remove({
|
||||
meetingId: meetingId,
|
||||
}, () => logger.info(`cleared Cursor Collection (meetingId: ${meetingId})!`));
|
||||
} else {
|
||||
return Cursor.remove({}, () => logger.info('cleared Cursor Collection (all meetings)!'));
|
||||
}
|
||||
};
|
@ -1,17 +1,8 @@
|
||||
import Cursor from '/imports/api/cursor';
|
||||
import { logger } from '/imports/startup/server/logger';
|
||||
import updateCursor from './updateCursor';
|
||||
|
||||
export function initializeCursor(meetingId) {
|
||||
return Cursor.upsert({
|
||||
meetingId: meetingId,
|
||||
}, {
|
||||
meetingId: meetingId,
|
||||
x: 0,
|
||||
y: 0,
|
||||
}, (err, numChanged) => {
|
||||
if (err) {
|
||||
return logger.error(`err upserting cursor for ${meetingId}`);
|
||||
}
|
||||
export default function initializeCursor(meetingId) {
|
||||
check(meetingId, String);
|
||||
|
||||
});
|
||||
return updateCursor(meetingId, 0, 0);
|
||||
};
|
||||
|
37
bigbluebutton-html5/imports/api/cursor/server/modifiers/updateCursor.js
Executable file
37
bigbluebutton-html5/imports/api/cursor/server/modifiers/updateCursor.js
Executable file
@ -0,0 +1,37 @@
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import Cursor from '/imports/api/cursor';
|
||||
|
||||
export default function updateCursor(meetingId, x = 0, y = 0) {
|
||||
check(meetingId, String);
|
||||
check(x, Number);
|
||||
check(y, Number);
|
||||
|
||||
const selector = {
|
||||
meetingId,
|
||||
};
|
||||
|
||||
const modifier = {
|
||||
$set: {
|
||||
meetingId,
|
||||
x,
|
||||
y,
|
||||
},
|
||||
};
|
||||
|
||||
const cb = (err, numChanged) => {
|
||||
if (err) {
|
||||
return Logger.error(`Upserting cursor to collection: ${err}`);
|
||||
}
|
||||
|
||||
const { insertedId } = numChanged;
|
||||
if (insertedId) {
|
||||
return Logger.info(`Initialized cursor meeting=${meetingId}`);
|
||||
}
|
||||
|
||||
if (numChanged) {
|
||||
return Logger.info(`Updated cursor meeting=${meetingId}`);
|
||||
}
|
||||
};
|
||||
|
||||
return Cursor.upsert(selector, modifier, cb);
|
||||
};
|
@ -1,19 +0,0 @@
|
||||
import Cursor from '/imports/api/cursor';
|
||||
import { logger } from '/imports/startup/server/logger';
|
||||
|
||||
export function updateCursorLocation(meetingId, cursorObject) {
|
||||
return Cursor.upsert({
|
||||
meetingId: meetingId,
|
||||
}, {
|
||||
$set: {
|
||||
meetingId: meetingId,
|
||||
x: cursorObject.x,
|
||||
y: cursorObject.y,
|
||||
},
|
||||
}, (err, numChanged) => {
|
||||
if (err != null) {
|
||||
return logger.error(`_unsucc update of cursor for ${meetingId} err=${JSON.stringify(err)}`);
|
||||
}
|
||||
|
||||
});
|
||||
};
|
22
bigbluebutton-html5/imports/api/cursor/server/publishers.js
Normal file
22
bigbluebutton-html5/imports/api/cursor/server/publishers.js
Normal file
@ -0,0 +1,22 @@
|
||||
import Cursor from '/imports/api/cursor';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { check } from 'meteor/check';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import { isAllowedTo } from '/imports/startup/server/userPermissions';
|
||||
|
||||
Meteor.publish('cursor', (credentials) => {
|
||||
// TODO: Some publishers have ACL and others dont
|
||||
// if (!isAllowedTo('@@@', credentials)) {
|
||||
// this.error(new Meteor.Error(402, "The user was not authorized to subscribe for 'cursor'"));
|
||||
// }
|
||||
|
||||
const { meetingId, requesterUserId, requesterToken } = credentials;
|
||||
|
||||
check(meetingId, String);
|
||||
check(requesterUserId, String);
|
||||
check(requesterToken, String);
|
||||
|
||||
Logger.info(`Publishing Cursor for ${meetingId} ${requesterUserId} ${requesterToken}`);
|
||||
|
||||
return Cursor.find({ meetingId });
|
||||
});
|
@ -1,7 +1,7 @@
|
||||
import { check } from 'meteor/check';
|
||||
import Meetings from '/imports/api/meetings';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import { initializeCursor } from '/imports/api/cursor/server/modifiers/initializeCursor';
|
||||
import initializeCursor from '/imports/api/cursor/server/modifiers/initializeCursor';
|
||||
|
||||
export default function addMeeting(meeting) {
|
||||
const APP_CONFIG = Meteor.settings.public.app;
|
||||
|
@ -7,7 +7,7 @@ import clearChats from '/imports/api/chat/server/modifiers/clearChats';
|
||||
import { clearShapesCollection } from '/imports/api/shapes/server/modifiers/clearShapesCollection';
|
||||
import clearSlides from '/imports/api/slides/server/modifiers/clearSlides';
|
||||
import clearPolls from '/imports/api/polls/server/modifiers/clearPolls';
|
||||
import { clearCursorCollection } from '/imports/api/cursor/server/modifiers/clearCursorCollection';
|
||||
import clearCursor from '/imports/api/cursor/server/modifiers/clearCursor';
|
||||
import { clearCaptionsCollection }
|
||||
from '/imports/api/captions/server/modifiers/clearCaptionsCollection';
|
||||
import clearPresentations from '/imports/api/presentations/server/modifiers/clearPresentations';
|
||||
@ -16,7 +16,7 @@ export default function clearMeetings() {
|
||||
return Meetings.remove({}, (err) => {
|
||||
clearCaptionsCollection();
|
||||
clearChats();
|
||||
clearCursorCollection();
|
||||
clearCursor();
|
||||
clearPresentations();
|
||||
clearPolls();
|
||||
clearShapesCollection();
|
||||
|
@ -7,7 +7,7 @@ import clearChats from '/imports/api/chat/server/modifiers/clearChats';
|
||||
import { clearShapesCollection } from '/imports/api/shapes/server/modifiers/clearShapesCollection';
|
||||
import clearSlides from '/imports/api/slides/server/modifiers/clearSlides';
|
||||
import clearPolls from '/imports/api/polls/server/modifiers/clearPolls';
|
||||
import { clearCursorCollection } from '/imports/api/cursor/server/modifiers/clearCursorCollection';
|
||||
import clearCursor from '/imports/api/cursor/server/modifiers/clearCursor';
|
||||
import { clearCaptionsCollection }
|
||||
from '/imports/api/captions/server/modifiers/clearCaptionsCollection';
|
||||
import clearPresentations from '/imports/api/presentations/server/modifiers/clearPresentations';
|
||||
|
@ -3,7 +3,7 @@ import Logger from '/imports/startup/server/logger';
|
||||
|
||||
export default function clearSlides(meetingId) {
|
||||
if (meetingId) {
|
||||
return Slides.remove({ meetingId: meetingId }, Logger.info(`Cleared Slides (${meetingId})`));
|
||||
return Slides.remove({ meetingId }, Logger.info(`Cleared Slides (${meetingId})`));
|
||||
} else {
|
||||
return Slides.remove({}, Logger.info('Cleared Slides (all)'));
|
||||
}
|
||||
|
@ -1,11 +1,7 @@
|
||||
import '/imports/startup/server';
|
||||
import '/imports/api/chat/server';
|
||||
|
||||
import '/imports/api/cursor/server/publications';
|
||||
import '/imports/api/cursor/server/modifiers/clearCursorCollection';
|
||||
import '/imports/api/cursor/server/modifiers/initializeCursor';
|
||||
import '/imports/api/cursor/server/modifiers/updateCursorLocation';
|
||||
import '/imports/api/cursor/server/modifiers/eventHandlers';
|
||||
import '/imports/api/cursor/server';
|
||||
|
||||
import '/imports/api/deskshare/server/publications';
|
||||
import '/imports/api/deskshare/server/modifiers/clearDeskshareCollection';
|
||||
|
Loading…
Reference in New Issue
Block a user