Added another check reducing wasteful and redundant object checks.
This commit is contained in:
parent
0cafbba7f7
commit
297d8bf9c9
@ -64,32 +64,32 @@ class Meteor.RedisPubSub
|
||||
"presentation_cursor_updated_message" # just because it's common. we handle it anyway
|
||||
]
|
||||
|
||||
if message.header?
|
||||
if message.header? and message.payload?
|
||||
unless message.header.name in ignoredEventTypes
|
||||
console.log "eventType=" + message.header.name #+ "\n"
|
||||
console.log jsonMsg
|
||||
|
||||
# handle voice events
|
||||
if message.header.name in ['user_left_voice_message', 'user_joined_voice_message', 'user_voice_talking_message', 'user_voice_muted_message']
|
||||
voiceUser = message.payload?.user?.voiceUser
|
||||
voiceUser = message.payload.user?.voiceUser
|
||||
updateVoiceUser meetingId, voiceUser
|
||||
|
||||
# listen only
|
||||
if message.header.name is 'user_listening_only'
|
||||
u = Meteor.Users.findOne({userId: message.payload?.userid, meetingId: meetingId})
|
||||
updateVoiceUser {'user_id': u._id, 'listenOnly': message.payload?.listen_only}
|
||||
u = Meteor.Users.findOne({userId: message.payload.userid, meetingId: meetingId})
|
||||
updateVoiceUser {'user_id': u._id, 'listenOnly': message.payload.listen_only}
|
||||
# most likely we don't need to ensure that the user's voiceUser's {talking, joined, muted, locked} are false by default #TODO?
|
||||
|
||||
if message.header.name is "get_all_meetings_reply"
|
||||
console.log "Let's store some data for the running meetings so that when an HTML5 client joins everything is ready!"
|
||||
listOfMeetings = message.payload?.meetings
|
||||
listOfMeetings = message.payload.meetings
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
for user in users
|
||||
user.timeOfJoining = message.header.current_time # TODO this might need to be removed
|
||||
addUserToCollection meetingId, user
|
||||
@ -100,44 +100,44 @@ class Meteor.RedisPubSub
|
||||
addUserToCollection meetingId, user
|
||||
|
||||
if message.header.name is "user_left_message"
|
||||
userId = message.payload?.user?.userid
|
||||
userId = message.payload.user?.userid
|
||||
if userId? and meetingId?
|
||||
removeUserFromMeeting meetingId, userId
|
||||
|
||||
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
|
||||
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
|
||||
addChatToCollection meetingId, chatMessage
|
||||
|
||||
if message.header.name is "send_public_chat_message" or message.header.name is "send_private_chat_message"
|
||||
messageObject = message.payload?.message
|
||||
messageObject = message.payload.message
|
||||
# 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
|
||||
|
||||
if message.header.name is "meeting_created_message"
|
||||
meetingName = message.payload?.name
|
||||
intendedForRecording = message.payload?.recorded
|
||||
voiceConf = message.payload?.voice_conf
|
||||
duration = message.payload?.duration
|
||||
meetingName = message.payload.name
|
||||
intendedForRecording = message.payload.recorded
|
||||
voiceConf = message.payload.voice_conf
|
||||
duration = message.payload.duration
|
||||
addMeetingToCollection meetingId, meetingName, intendedForRecording, voiceConf, duration
|
||||
|
||||
if message.header.name is "presentation_shared_message"
|
||||
presentationId = message.payload?.presentation?.id
|
||||
presentationId = message.payload.presentation?.id
|
||||
# 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
|
||||
addPresentationToCollection meetingId, message.payload?.presentation
|
||||
addPresentationToCollection meetingId, message.payload.presentation
|
||||
|
||||
for slide in message.payload?.presentation?.pages
|
||||
addSlideToCollection meetingId, message.payload?.presentation?.id, slide
|
||||
for slide in message.payload.presentation?.pages
|
||||
addSlideToCollection meetingId, message.payload.presentation?.id, slide
|
||||
if slide.current
|
||||
displayThisSlide meetingId, slide.id, slide
|
||||
|
||||
if message.header.name is "get_presentation_info_reply" and message.payload?.requester_id is "nodeJSapp"
|
||||
for presentation in message.payload?.presentations
|
||||
if message.header.name is "get_presentation_info_reply" and message.payload.requester_id is "nodeJSapp"
|
||||
for presentation in message.payload.presentations
|
||||
addPresentationToCollection meetingId, presentation
|
||||
|
||||
for page in presentation.pages
|
||||
@ -164,35 +164,35 @@ class Meteor.RedisPubSub
|
||||
console.log "did not have enough information to send a user_leaving_request"
|
||||
|
||||
if message.header.name is "presentation_page_changed_message"
|
||||
newSlide = message.payload?.page
|
||||
newSlide = message.payload.page
|
||||
displayThisSlide meetingId, newSlide?.id, newSlide
|
||||
|
||||
if message.header.name is "get_whiteboard_shapes_reply" and message.payload?.requester_id is "nodeJSapp"
|
||||
if message.header.name is "get_whiteboard_shapes_reply" and message.payload.requester_id is "nodeJSapp"
|
||||
for shape in message.payload.shapes
|
||||
whiteboardId = shape.wb_id
|
||||
addShapeToCollection meetingId, whiteboardId, shape
|
||||
|
||||
if message.header.name is "send_whiteboard_shape_message"
|
||||
shape = message.payload?.shape
|
||||
shape = message.payload.shape
|
||||
whiteboardId = shape?.wb_id
|
||||
addShapeToCollection meetingId, whiteboardId, shape
|
||||
|
||||
if message.header.name is "presentation_cursor_updated_message"
|
||||
x = message.payload?.x_percent
|
||||
y = message.payload?.y_percent
|
||||
x = message.payload.x_percent
|
||||
y = message.payload.y_percent
|
||||
Meteor.Presentations.update({"presentation.current": true, meetingId: meetingId},{$set: {"pointer.x": x, "pointer.y": y}})
|
||||
|
||||
if message.header.name is "whiteboard_cleared_message"
|
||||
whiteboardId = message.payload?.whiteboard_id
|
||||
whiteboardId = message.payload.whiteboard_id
|
||||
removeAllShapesFromSlide meetingId, whiteboardId
|
||||
|
||||
if message.header.name is "undo_whiteboard_request"
|
||||
whiteboardId = message.payload?.whiteboard_id
|
||||
shapeId = message.payload?.shape_id
|
||||
whiteboardId = message.payload.whiteboard_id
|
||||
shapeId = message.payload.shape_id
|
||||
removeShapeFromSlide meetingId, whiteboardId, shapeId
|
||||
|
||||
if message.header.name is "presenter_assigned_message"
|
||||
newPresenterId = message.payload?.new_presenter_id
|
||||
newPresenterId = message.payload.new_presenter_id
|
||||
if newPresenterId?
|
||||
# reset the previous presenter
|
||||
Meteor.Users.update({"user.presenter": true, meetingId: meetingId},{$set: {"user.presenter": false}})
|
||||
@ -200,27 +200,27 @@ class Meteor.RedisPubSub
|
||||
Meteor.Users.update({"user.userid": newPresenterId, meetingId: meetingId},{$set: {"user.presenter": true}})
|
||||
|
||||
if message.header.name is "presentation_page_resized_message"
|
||||
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
|
||||
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
|
||||
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}})
|
||||
|
||||
if message.header.name is "user_raised_hand_message"
|
||||
userId = message.payload?.userid
|
||||
userId = message.payload.userid
|
||||
# update the user
|
||||
Meteor.Users.update({"user.userid": userId, meetingId: meetingId},{$set: {"user.raise_hand": true}}) #not sure why but message.payload?.raise_hand is awlays false
|
||||
Meteor.Users.update({"user.userid": userId, meetingId: meetingId},{$set: {"user.raise_hand": true}}) #not sure why but message.payload.raise_hand is awlays false
|
||||
|
||||
if message.header.name is "user_lowered_hand_message"
|
||||
userId = message.payload?.userid
|
||||
userId = message.payload.userid
|
||||
# update the user
|
||||
Meteor.Users.update({"user.userid": userId, meetingId: meetingId},{$set: {"user.raise_hand": false}}) #not sure why but message.payload?.raise_hand is awlays false
|
||||
Meteor.Users.update({"user.userid": userId, meetingId: meetingId},{$set: {"user.raise_hand": false}}) #not sure why but message.payload.raise_hand is awlays false
|
||||
|
||||
if message.header.name is "recording_status_changed_message"
|
||||
intendedForRecording = message.payload?.recorded
|
||||
currentlyBeingRecorded = message.payload?.recording
|
||||
intendedForRecording = message.payload.recorded
|
||||
currentlyBeingRecorded = message.payload.recording
|
||||
Meteor.Meetings.update({meetingId: meetingId, intendedForRecording: intendedForRecording}, {$set: {currentlyBeingRecorded: currentlyBeingRecorded}})
|
||||
|
||||
if message.header.name in ["meeting_ended_message", "meeting_destroyed_event",
|
||||
|
Loading…
Reference in New Issue
Block a user