2015-05-06 23:54:39 +08:00
Meteor . methods
2015-05-07 00:46:32 +08:00
publishSwitchToPreviousSlideMessage: (meetingId, userId, authToken) ->
2015-05-06 23:54:39 +08:00
currentPresentationDoc = Meteor . Presentations . findOne ( {
" meetingId " : meetingId
" presentation.current " : true } )
currentSlideDoc = Meteor . Slides . findOne ( {
" meetingId " : meetingId
" presentationId " : currentPresentationDoc ? . presentation . id
" slide.current " : true } )
previousSlideDoc = Meteor . Slides . findOne ( {
" meetingId " : meetingId
" presentationId " : currentPresentationDoc ? . presentation . id
" slide.num " : currentSlideDoc ? . slide . num - 1 } )
2015-05-07 00:46:32 +08:00
if previousSlideDoc ? and isAllowedTo ( ' switchSlide ' , meetingId , userId , authToken )
2015-05-06 23:54:39 +08:00
newPage = previousSlideDoc . slide . id
message =
" payload " :
" page " :
" id " : previousSlideDoc . slide . id
" meeting_id " : meetingId
" header " :
" timestamp " : new Date ( ) . getTime ( )
" name " : " presentation_page_changed_message "
publish Meteor . config . redis . channels . toBBBApps . presentation , message
2015-05-07 00:46:32 +08:00
publishSwitchToNextSlideMessage: (meetingId, userId, authToken) ->
2015-05-06 23:54:39 +08:00
currentPresentationDoc = Meteor . Presentations . findOne ( {
" meetingId " : meetingId
" presentation.current " : true } )
currentSlideDoc = Meteor . Slides . findOne ( {
" meetingId " : meetingId
" presentationId " : currentPresentationDoc ? . presentation . id
" slide.current " : true } )
nextSlideDoc = Meteor . Slides . findOne ( {
" meetingId " : meetingId
" presentationId " : currentPresentationDoc ? . presentation . id
" slide.num " : currentSlideDoc ? . slide . num + 1 } )
2015-05-07 00:46:32 +08:00
if nextSlideDoc ? and isAllowedTo ( ' switchSlide ' , meetingId , userId , authToken )
2015-05-06 23:54:39 +08:00
newPage = nextSlideDoc . slide . id
message =
" payload " :
" page " :
" id " : nextSlideDoc . slide . id
" meeting_id " : meetingId
" header " :
" timestamp " : new Date ( ) . getTime ( )
" name " : " presentation_page_changed_message "
publish Meteor . config . redis . channels . toBBBApps . presentation , message
2014-10-01 01:02:36 +08:00
# --------------------------------------------------------------------------------------------
# Private methods on server
# --------------------------------------------------------------------------------------------
2014-10-01 01:12:47 +08:00
@addPresentationToCollection = (meetingId, presentationObject) ->
#check if the presentation is already in the collection
unless Meteor . Presentations . findOne ( { meetingId: meetingId , ' presentation.id ' : presentationObject . id } ) ?
entry =
meetingId: meetingId
presentation:
id: presentationObject . id
name: presentationObject . name
current: presentationObject . current
2014-09-26 03:20:00 +08:00
2014-10-01 01:12:47 +08:00
pointer: #initially we have no data about the cursor
x: 0.0
y: 0.0
2014-07-30 05:30:16 +08:00
2014-10-01 01:12:47 +08:00
id = Meteor . Presentations . insert ( entry )
2014-10-25 02:02:01 +08:00
#Meteor.log.info "presentation added id =[#{id}]:#{presentationObject.id} in #{meetingId}. Presentations.size is now #{Meteor.Presentations.find({meetingId: meetingId}).count()}"
2014-08-12 04:54:16 +08:00
2014-10-01 01:12:47 +08:00
@removePresentationFromCollection = (meetingId, presentationId) ->
if meetingId ? and presentationId ? and Meteor . Presentations . findOne ( { meetingId: meetingId , " presentation.id " : presentationId } ) ?
id = Meteor . Presentations . findOne ( { meetingId: meetingId , " presentation.id " : presentationId } )
if id ?
Meteor . Presentations . remove ( id . _id )
2014-10-25 02:02:01 +08:00
Meteor . log . info " ----removed presentation[ " + presentationId + " ] from " + meetingId
2014-12-23 03:43:27 +08:00
# called on server start and meeting end
@clearPresentationsCollection = (meetingId) ->
if meetingId ?
Meteor . Presentations . remove ( { meetingId: meetingId } , Meteor . log . info " cleared Presentations Collection (meetingId: #{ meetingId } ! " )
else
Meteor . Presentations . remove ( { } , Meteor . log . info " cleared Presentations Collection (all meetings)! " )
2014-10-01 01:02:36 +08:00
# --------------------------------------------------------------------------------------------
# end Private methods on server
# --------------------------------------------------------------------------------------------