2014-06-19 04:11:29 +08:00
|
|
|
Meteor.methods
|
2014-08-14 02:30:55 +08:00
|
|
|
|
2014-09-24 03:59:56 +08:00
|
|
|
# Construct and send a message to bbb-web to validate the user
|
2014-08-08 21:09:39 +08:00
|
|
|
validateAuthToken: (meetingId, userId, authToken) ->
|
2014-10-25 02:02:01 +08:00
|
|
|
Meteor.log.info "sending a validate_auth_token with",
|
|
|
|
userid: userId
|
|
|
|
authToken: authToken
|
|
|
|
meetingid: meetingId
|
2014-09-24 03:59:56 +08:00
|
|
|
|
|
|
|
message =
|
|
|
|
"payload":
|
|
|
|
"auth_token": authToken
|
|
|
|
"userid": userId
|
|
|
|
"meeting_id": meetingId
|
|
|
|
"header":
|
|
|
|
"timestamp": new Date().getTime()
|
|
|
|
"reply_to": meetingId + "/" + userId
|
|
|
|
"name": "validate_auth_token"
|
|
|
|
|
|
|
|
if authToken? and userId? and meetingId?
|
2015-02-07 01:21:31 +08:00
|
|
|
createDummyUser meetingId, userId, authToken
|
2014-09-26 02:47:43 +08:00
|
|
|
publish Meteor.config.redis.channels.toBBBApps.meeting, message
|
2014-09-24 03:59:56 +08:00
|
|
|
else
|
2014-10-25 02:02:01 +08:00
|
|
|
Meteor.log.info "did not have enough information to send a validate_auth_token message"
|
2014-06-19 04:11:29 +08:00
|
|
|
|
2014-06-12 03:26:46 +08:00
|
|
|
class Meteor.RedisPubSub
|
2014-06-27 02:09:39 +08:00
|
|
|
constructor: (callback) ->
|
2014-10-25 02:02:01 +08:00
|
|
|
Meteor.log.info "constructor RedisPubSub"
|
2014-06-12 03:26:46 +08:00
|
|
|
|
2014-06-14 03:27:26 +08:00
|
|
|
@pubClient = redis.createClient()
|
|
|
|
@subClient = redis.createClient()
|
2014-10-28 10:19:56 +08:00
|
|
|
|
2014-10-25 02:02:01 +08:00
|
|
|
Meteor.log.info("Subscribing message on channel: #{Meteor.config.redis.channels.fromBBBApps}")
|
2014-06-12 03:26:46 +08:00
|
|
|
|
2014-06-27 02:09:39 +08:00
|
|
|
@subClient.on "psubscribe", Meteor.bindEnvironment(@_onSubscribe)
|
2014-06-17 23:22:12 +08:00
|
|
|
@subClient.on "pmessage", Meteor.bindEnvironment(@_onMessage)
|
2014-06-12 03:26:46 +08:00
|
|
|
|
2014-06-14 03:27:26 +08:00
|
|
|
@subClient.psubscribe(Meteor.config.redis.channels.fromBBBApps)
|
2014-06-27 02:09:39 +08:00
|
|
|
callback @
|
2014-06-12 03:26:46 +08:00
|
|
|
|
2014-06-27 02:09:39 +08:00
|
|
|
_onSubscribe: (channel, count) =>
|
2014-10-25 02:02:01 +08:00
|
|
|
Meteor.log.info "Subscribed to #{channel}"
|
2014-09-24 04:15:03 +08:00
|
|
|
|
|
|
|
#grab data about all active meetings on the server
|
|
|
|
message =
|
|
|
|
"header":
|
|
|
|
"name": "get_all_meetings_request"
|
|
|
|
"payload": {} # I need this, otherwise bbb-apps won't recognize the message
|
2014-09-26 02:47:43 +08:00
|
|
|
publish Meteor.config.redis.channels.toBBBApps.meeting, message
|
2014-06-27 02:09:39 +08:00
|
|
|
|
2014-06-17 23:22:12 +08:00
|
|
|
_onMessage: (pattern, channel, jsonMsg) =>
|
|
|
|
# TODO: this has to be in a try/catch block, otherwise the server will
|
|
|
|
# crash if the message has a bad format
|
2014-06-18 01:04:58 +08:00
|
|
|
|
2014-06-17 23:22:12 +08:00
|
|
|
message = JSON.parse(jsonMsg)
|
|
|
|
correlationId = message.payload?.reply_to or message.header?.reply_to
|
2014-07-08 04:21:36 +08:00
|
|
|
meetingId = message.payload?.meeting_id
|
2014-06-18 01:04:58 +08:00
|
|
|
|
2015-03-31 01:49:30 +08:00
|
|
|
# just because it's common. we handle it anyway
|
|
|
|
notLoggedEventTypes = [
|
2014-07-08 04:51:33 +08:00
|
|
|
"keep_alive_reply"
|
|
|
|
"page_resized_message"
|
2014-09-24 01:20:18 +08:00
|
|
|
"presentation_page_resized_message"
|
2015-03-31 01:49:30 +08:00
|
|
|
"presentation_cursor_updated_message"
|
|
|
|
"get_presentation_info_reply"
|
|
|
|
# "get_users_reply"
|
|
|
|
"get_chat_history_reply"
|
|
|
|
"get_all_meetings_reply"
|
2015-03-31 06:48:25 +08:00
|
|
|
"presentation_shared_message"
|
|
|
|
"presentation_conversion_done_message"
|
|
|
|
"presentation_conversion_progress_message"
|
|
|
|
"presentation_page_generated_message"
|
|
|
|
"presentation_page_changed_message"
|
2014-07-08 04:51:33 +08:00
|
|
|
]
|
|
|
|
|
2014-10-04 01:32:14 +08:00
|
|
|
if message?.header? and message?.payload?
|
2015-03-31 01:49:30 +08:00
|
|
|
unless message.header.name in notLoggedEventTypes
|
2014-12-11 00:24:22 +08:00
|
|
|
Meteor.log.info "eventType= #{message.header.name} ",
|
2014-10-25 02:02:01 +08:00
|
|
|
message: jsonMsg
|
2014-10-02 22:37:51 +08:00
|
|
|
|
|
|
|
# handle voice events
|
|
|
|
if message.header.name in ['user_left_voice_message', 'user_joined_voice_message', 'user_voice_talking_message', 'user_voice_muted_message']
|
2015-04-11 02:01:45 +08:00
|
|
|
if message.payload.user?
|
|
|
|
updateVoiceUser meetingId,
|
|
|
|
'web_userid': message.payload.user.voiceUser.web_userid
|
|
|
|
'listen_only': message.payload.listen_only
|
|
|
|
'talking': message.payload.user.voiceUser.talking
|
|
|
|
'joined': message.payload.user.voiceUser.joined
|
|
|
|
'locked': message.payload.user.voiceUser.locked
|
|
|
|
'muted': message.payload.user.voiceUser.muted
|
2014-10-08 03:52:30 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
|
|
|
# listen only
|
|
|
|
if message.header.name is 'user_listening_only'
|
2015-04-02 23:06:39 +08:00
|
|
|
updateVoiceUser meetingId, {'web_userid': message.payload.userid, 'listen_only': message.payload.listen_only}
|
2014-10-02 22:37:51 +08:00
|
|
|
# most likely we don't need to ensure that the user's voiceUser's {talking, joined, muted, locked} are false by default #TODO?
|
2015-04-02 23:06:39 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
|
|
|
if message.header.name is "get_all_meetings_reply"
|
2014-10-25 02:02:01 +08:00
|
|
|
Meteor.log.info "Let's store some data for the running meetings so that when an HTML5 client joins everything is ready!"
|
2014-10-02 22:40:18 +08:00
|
|
|
listOfMeetings = message.payload.meetings
|
2014-10-02 22:37:51 +08:00
|
|
|
for meeting in listOfMeetings
|
|
|
|
# we currently do not have voice_conf or duration in this message.
|
|
|
|
addMeetingToCollection meeting.meetingID, meeting.meetingName, meeting.recorded, meeting.voiceBridge, meeting.duration
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
2014-10-02 22:40:18 +08:00
|
|
|
if message.header.name is "get_users_reply" and message.payload.requester_id is "nodeJSapp"
|
|
|
|
unless Meteor.Meetings.findOne({MeetingId: message.payload.meeting_id})?
|
|
|
|
users = message.payload.users
|
2014-10-02 22:37:51 +08:00
|
|
|
for user in users
|
|
|
|
user.timeOfJoining = message.header.current_time # TODO this might need to be removed
|
2014-11-21 05:32:51 +08:00
|
|
|
userJoined meetingId, user
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
2014-11-11 21:38:39 +08:00
|
|
|
if message.header.name is "validate_auth_token_reply"
|
2015-02-07 01:21:31 +08:00
|
|
|
user = Meteor.Users.findOne({userId:message.payload.userid, meetingId: message.payload.meeting_id})
|
|
|
|
validStatus = message.payload.valid
|
|
|
|
|
|
|
|
# if the user already exists in the db
|
|
|
|
if user?.clientType is "HTML5"
|
|
|
|
#if the html5 client user was validated successfully, add a flag
|
|
|
|
Meteor.Users.update({userId:message.payload.userid, meetingId:message.payload.meeting_id}, {$set:{validated: validStatus}})
|
|
|
|
Meteor.log.info "user.validated for user #{user.userId} in meeting #{user.meetingId} just
|
|
|
|
became #{Meteor.Users.findOne({userId:message.payload.userid, meetingId: message.payload.meeting_id})?.validated}"
|
|
|
|
else
|
|
|
|
Meteor.log.info "a non-html5 user got validate_auth_token_reply."
|
2014-11-21 05:32:51 +08:00
|
|
|
return
|
|
|
|
|
|
|
|
if message.header.name is "user_registered_message"
|
2015-02-07 01:21:31 +08:00
|
|
|
#createDummyUser message.payload.meeting_id, message.payload.user
|
2014-11-11 21:38:39 +08:00
|
|
|
return
|
|
|
|
|
2014-10-02 22:37:51 +08:00
|
|
|
if message.header.name is "user_joined_message"
|
2015-02-07 01:21:31 +08:00
|
|
|
userObj = message.payload.user
|
|
|
|
dbUser = Meteor.Users.findOne({userId: message.payload.user.userid, meetingId: message.payload.meeting_id})
|
|
|
|
if dbUser?.clientType is "HTML5" # typically html5 users will be in the db [as a dummy user] before the joining message
|
|
|
|
status = dbUser?.validated
|
|
|
|
Meteor.log.info "in user_joined_message the validStatus of the user was #{status}"
|
|
|
|
userJoined meetingId, userObj
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
|
|
|
if message.header.name is "user_left_message"
|
2014-10-02 22:40:18 +08:00
|
|
|
userId = message.payload.user?.userid
|
2014-10-02 22:37:51 +08:00
|
|
|
if userId? and meetingId?
|
2014-11-22 04:51:37 +08:00
|
|
|
markUserOffline meetingId, userId
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
2014-12-10 04:45:20 +08:00
|
|
|
if message.header.name is "disconnect_user_message"
|
|
|
|
Meteor.log.info "a user(#{message.payload.userid}) was kicked out from meeting(#{message.payload.meeting_id})"
|
|
|
|
return
|
|
|
|
|
2014-10-02 22:40:18 +08:00
|
|
|
if message.header.name is "get_chat_history_reply" and message.payload.requester_id is "nodeJSapp"
|
|
|
|
unless Meteor.Meetings.findOne({MeetingId: message.payload.meeting_id})?
|
|
|
|
for chatMessage in message.payload.chat_history
|
2014-10-02 22:37:51 +08:00
|
|
|
addChatToCollection meetingId, chatMessage
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
|
|
|
if message.header.name is "send_public_chat_message" or message.header.name is "send_private_chat_message"
|
2014-10-02 22:40:18 +08:00
|
|
|
messageObject = message.payload.message
|
2014-10-02 22:37:51 +08:00
|
|
|
# use current_time instead of message.from_time so that the chats from Flash and HTML5 have uniform times
|
|
|
|
messageObject.from_time = message.header.current_time
|
|
|
|
addChatToCollection meetingId, messageObject
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
|
|
|
if message.header.name is "meeting_created_message"
|
2014-10-02 22:40:18 +08:00
|
|
|
meetingName = message.payload.name
|
|
|
|
intendedForRecording = message.payload.recorded
|
|
|
|
voiceConf = message.payload.voice_conf
|
|
|
|
duration = message.payload.duration
|
2014-10-02 22:37:51 +08:00
|
|
|
addMeetingToCollection meetingId, meetingName, intendedForRecording, voiceConf, duration
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
|
|
|
if message.header.name is "presentation_shared_message"
|
2014-10-02 22:40:18 +08:00
|
|
|
presentationId = message.payload.presentation?.id
|
2014-10-02 22:37:51 +08:00
|
|
|
# change the currently displayed presentation to presentation.current = false
|
|
|
|
Meteor.Presentations.update({"presentation.current": true, meetingId: meetingId},{$set: {"presentation.current": false}})
|
|
|
|
|
|
|
|
#update(if already present) entirely the presentation with the fresh data
|
|
|
|
removePresentationFromCollection meetingId, presentationId
|
2014-10-02 22:40:18 +08:00
|
|
|
addPresentationToCollection meetingId, message.payload.presentation
|
2014-10-02 22:37:51 +08:00
|
|
|
|
2014-10-02 22:40:18 +08:00
|
|
|
for slide in message.payload.presentation?.pages
|
|
|
|
addSlideToCollection meetingId, message.payload.presentation?.id, slide
|
2014-10-02 22:37:51 +08:00
|
|
|
if slide.current
|
|
|
|
displayThisSlide meetingId, slide.id, slide
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
2014-10-02 22:40:18 +08:00
|
|
|
if message.header.name is "get_presentation_info_reply" and message.payload.requester_id is "nodeJSapp"
|
|
|
|
for presentation in message.payload.presentations
|
2014-10-02 22:37:51 +08:00
|
|
|
addPresentationToCollection meetingId, presentation
|
|
|
|
|
|
|
|
for page in presentation.pages
|
|
|
|
#add the slide to the collection
|
|
|
|
addSlideToCollection meetingId, presentation.id, page
|
|
|
|
|
|
|
|
#request for shapes
|
|
|
|
whiteboardId = "#{presentation.id}/#{page.num}" # d2d9a672040fbde2a47a10bf6c37b6a4b5ae187f-1404411622872/1
|
2014-11-21 05:32:51 +08:00
|
|
|
#Meteor.log.info "the whiteboard_id here is:" + whiteboardId
|
2014-10-02 22:37:51 +08:00
|
|
|
|
|
|
|
message =
|
|
|
|
"payload":
|
|
|
|
"meeting_id": meetingId
|
|
|
|
"requester_id": "nodeJSapp"
|
|
|
|
"whiteboard_id": whiteboardId
|
|
|
|
"header":
|
|
|
|
"timestamp": new Date().getTime()
|
|
|
|
"name": "get_whiteboard_shapes_request"
|
|
|
|
"version": "0.0.1"
|
|
|
|
|
|
|
|
if whiteboardId? and meetingId?
|
|
|
|
publish Meteor.config.redis.channels.toBBBApps.whiteboard, message
|
|
|
|
else
|
2014-10-25 02:02:01 +08:00
|
|
|
Meteor.log.info "did not have enough information to send a user_leaving_request"
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
|
|
|
if message.header.name is "presentation_page_changed_message"
|
2014-10-02 22:40:18 +08:00
|
|
|
newSlide = message.payload.page
|
2014-10-02 22:37:51 +08:00
|
|
|
displayThisSlide meetingId, newSlide?.id, newSlide
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
2014-10-02 22:40:18 +08:00
|
|
|
if message.header.name is "get_whiteboard_shapes_reply" and message.payload.requester_id is "nodeJSapp"
|
2015-03-07 03:47:07 +08:00
|
|
|
|
|
|
|
# Create a whiteboard clean status or find one for the current meeting
|
|
|
|
if not Meteor.WhiteboardCleanStatus.findOne({meetingId: meetingId})?
|
|
|
|
Meteor.WhiteboardCleanStatus.insert({meetingId: meetingId, in_progress: false})
|
|
|
|
|
2014-10-02 22:37:51 +08:00
|
|
|
for shape in message.payload.shapes
|
|
|
|
whiteboardId = shape.wb_id
|
|
|
|
addShapeToCollection meetingId, whiteboardId, shape
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
|
|
|
if message.header.name is "send_whiteboard_shape_message"
|
2014-10-02 22:40:18 +08:00
|
|
|
shape = message.payload.shape
|
2014-10-02 22:37:51 +08:00
|
|
|
whiteboardId = shape?.wb_id
|
2014-10-01 01:02:36 +08:00
|
|
|
addShapeToCollection meetingId, whiteboardId, shape
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-07-08 02:04:47 +08:00
|
|
|
|
2014-10-02 22:37:51 +08:00
|
|
|
if message.header.name is "presentation_cursor_updated_message"
|
2014-10-02 22:40:18 +08:00
|
|
|
x = message.payload.x_percent
|
|
|
|
y = message.payload.y_percent
|
2014-10-02 22:37:51 +08:00
|
|
|
Meteor.Presentations.update({"presentation.current": true, meetingId: meetingId},{$set: {"pointer.x": x, "pointer.y": y}})
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
|
|
|
if message.header.name is "whiteboard_cleared_message"
|
2014-10-02 22:40:18 +08:00
|
|
|
whiteboardId = message.payload.whiteboard_id
|
2015-03-07 03:47:07 +08:00
|
|
|
Meteor.WhiteboardCleanStatus.update({meetingId: meetingId}, {$set: {'in_progress': true}})
|
2014-10-02 22:37:51 +08:00
|
|
|
removeAllShapesFromSlide meetingId, whiteboardId
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
|
|
|
if message.header.name is "undo_whiteboard_request"
|
2014-10-02 22:40:18 +08:00
|
|
|
whiteboardId = message.payload.whiteboard_id
|
|
|
|
shapeId = message.payload.shape_id
|
2014-10-02 22:37:51 +08:00
|
|
|
removeShapeFromSlide meetingId, whiteboardId, shapeId
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
|
|
|
if message.header.name is "presenter_assigned_message"
|
2014-10-02 22:40:18 +08:00
|
|
|
newPresenterId = message.payload.new_presenter_id
|
2014-10-02 22:37:51 +08:00
|
|
|
if newPresenterId?
|
|
|
|
# reset the previous presenter
|
|
|
|
Meteor.Users.update({"user.presenter": true, meetingId: meetingId},{$set: {"user.presenter": false}})
|
|
|
|
# set the new presenter
|
|
|
|
Meteor.Users.update({"user.userid": newPresenterId, meetingId: meetingId},{$set: {"user.presenter": true}})
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
|
|
|
if message.header.name is "presentation_page_resized_message"
|
2014-10-02 22:40:18 +08:00
|
|
|
slideId = message.payload.page?.id
|
|
|
|
heightRatio = message.payload.page?.height_ratio
|
|
|
|
widthRatio = message.payload.page?.width_ratio
|
|
|
|
xOffset = message.payload.page?.x_offset
|
|
|
|
yOffset = message.payload.page?.y_offset
|
2014-10-02 22:37:51 +08:00
|
|
|
presentationId = slideId.split("/")[0]
|
|
|
|
Meteor.Slides.update({presentationId: presentationId, "slide.current": true}, {$set: {"slide.height_ratio": heightRatio, "slide.width_ratio": widthRatio, "slide.x_offset": xOffset, "slide.y_offset": yOffset}})
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
|
|
|
if message.header.name is "user_raised_hand_message"
|
2014-10-02 22:40:18 +08:00
|
|
|
userId = message.payload.userid
|
2014-10-08 03:28:54 +08:00
|
|
|
meetingId = message.payload.meeting_id
|
|
|
|
if userId? and meetingId?
|
2014-12-13 04:58:54 +08:00
|
|
|
last_raised = new Date()
|
|
|
|
Meteor.Users.update({"user.userid": userId},{$set: {"user.raise_hand": last_raised}})
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
|
|
|
if message.header.name is "user_lowered_hand_message"
|
2014-10-02 22:40:18 +08:00
|
|
|
userId = message.payload.userid
|
2014-10-08 03:28:54 +08:00
|
|
|
meetingId = message.payload.meeting_id
|
|
|
|
if userId? and meetingId?
|
2014-12-13 04:58:54 +08:00
|
|
|
Meteor.Users.update({"user.userid": userId, meetingId: meetingId},{$set: {"user.raise_hand": 0}})
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
|
|
|
if message.header.name is "recording_status_changed_message"
|
2014-10-02 22:40:18 +08:00
|
|
|
intendedForRecording = message.payload.recorded
|
|
|
|
currentlyBeingRecorded = message.payload.recording
|
2014-10-02 22:37:51 +08:00
|
|
|
Meteor.Meetings.update({meetingId: meetingId, intendedForRecording: intendedForRecording}, {$set: {currentlyBeingRecorded: currentlyBeingRecorded}})
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-10-02 22:37:51 +08:00
|
|
|
|
2015-03-31 01:49:30 +08:00
|
|
|
# --------------------------------------------------
|
|
|
|
# lock settings ------------------------------------
|
|
|
|
if message.header.name is "eject_voice_user_message"
|
|
|
|
console.log "\n111111111"
|
|
|
|
return
|
|
|
|
|
|
|
|
if message.header.name is "new_permission_settings"
|
2015-04-24 03:55:38 +08:00
|
|
|
oldSettings = Meteor.Meetings.findOne({meetingId:meetingId})?.roomLockSettings
|
|
|
|
newSettings = message.payload
|
|
|
|
|
|
|
|
# if the disableMic setting was turned on
|
2015-04-27 22:42:03 +08:00
|
|
|
if !oldSettings?.disableMic and newSettings.disableMic
|
2015-04-24 03:55:38 +08:00
|
|
|
handleLockingMic(meetingId, newSettings)
|
2015-03-31 01:49:30 +08:00
|
|
|
|
|
|
|
# substitute with the new lock settings
|
|
|
|
Meteor.Meetings.update({meetingId: meetingId}, {$set: {
|
|
|
|
'roomLockSettings.disablePrivChat': message.payload.disablePrivChat
|
|
|
|
'roomLockSettings.disableCam': message.payload.disableCam
|
|
|
|
'roomLockSettings.disableMic': message.payload.disableMic
|
|
|
|
'roomLockSettings.lockOnJoin': message.payload.lockOnJoin
|
|
|
|
'roomLockSettings.lockedLayout': message.payload.lockedLayout
|
|
|
|
'roomLockSettings.disablePubChat': message.payload.disablePubChat
|
|
|
|
}})
|
|
|
|
return
|
|
|
|
|
|
|
|
if message.header.name is "user_locked_message" or message.header.name is "user_unlocked_message"
|
|
|
|
userId = message.payload.userid
|
|
|
|
isLocked = message.payload.locked
|
|
|
|
setUserLockedStatus(meetingId, userId, isLocked)
|
|
|
|
return
|
|
|
|
|
2014-10-02 22:37:51 +08:00
|
|
|
if message.header.name in ["meeting_ended_message", "meeting_destroyed_event",
|
|
|
|
"end_and_kick_all_message", "disconnect_all_users_message"]
|
|
|
|
if Meteor.Meetings.findOne({meetingId: meetingId})?
|
2014-10-25 02:02:01 +08:00
|
|
|
Meteor.log.info "there are #{Meteor.Users.find({meetingId: meetingId}).count()} users in the meeting"
|
2014-10-02 22:37:51 +08:00
|
|
|
for user in Meteor.Users.find({meetingId: meetingId}).fetch()
|
2014-11-22 04:51:37 +08:00
|
|
|
markUserOffline meetingId, user.userId
|
2014-10-02 22:37:51 +08:00
|
|
|
#TODO should we clear the chat messages for that meeting?!
|
|
|
|
unless message.header.name is "disconnect_all_users_message"
|
|
|
|
removeMeetingFromCollection meetingId
|
2014-10-02 22:44:53 +08:00
|
|
|
return
|
2014-09-26 02:29:43 +08:00
|
|
|
|
2015-07-22 07:55:42 +08:00
|
|
|
if message.header.name is "poll_started_message"
|
2015-07-27 06:12:08 +08:00
|
|
|
if message.payload.meeting_id? and message.payload.requester_id? and message.payload.poll?
|
|
|
|
if Meteor.Meetings.findOne({meetingId: message.payload.meeting_id})?
|
|
|
|
#initializing the list of current users
|
|
|
|
users = Meteor.Users.find({meetingId: message.payload.meeting_id}, {fields:{"user.userid": 1, _id: 0}} ).fetch()
|
|
|
|
addPollToCollection message.payload.poll, message.payload.requester_id, users, message.payload.meeting_id
|
2015-07-22 07:55:42 +08:00
|
|
|
|
2015-07-28 02:23:29 +08:00
|
|
|
if message.header.name is "poll_stopped_message"
|
|
|
|
meetingId = message.payload.meeting_id
|
|
|
|
poll_id = message.payload.poll_id
|
|
|
|
clearPollCollection meetingId, poll_id
|
|
|
|
|
2015-08-02 03:27:01 +08:00
|
|
|
if message.header.name is "user_voted_poll_message"
|
|
|
|
if message.payload?.poll? and message.payload.meeting_id? and message.payload.presenter_id?
|
|
|
|
pollObj = message.payload.poll
|
|
|
|
meetingId = message.payload.meeting_id
|
|
|
|
requesterId = message.payload.presenter_id
|
|
|
|
updatePollCollection pollObj, meetingId, requesterId
|
|
|
|
|
2014-09-26 02:29:43 +08:00
|
|
|
# --------------------------------------------------------------------------------------------
|
|
|
|
# Private methods on server
|
|
|
|
# --------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# message should be an object
|
|
|
|
@publish = (channel, message) ->
|
2015-03-31 01:49:30 +08:00
|
|
|
# Meteor.log.info "Publishing",
|
|
|
|
# channel: channel
|
|
|
|
# message: message
|
2014-10-25 02:02:01 +08:00
|
|
|
|
|
|
|
if Meteor.redisPubSub?
|
|
|
|
Meteor.redisPubSub.pubClient.publish channel, JSON.stringify(message), (err, res) ->
|
|
|
|
if err
|
|
|
|
Meteor.log.info "error",
|
|
|
|
error: err
|
|
|
|
|
|
|
|
else
|
|
|
|
Meteor.log.info "ERROR!! Meteor.redisPubSub was undefined"
|