inserting the chat messages we receive from bbb-apps into the Chat collection

This commit is contained in:
Anton Georgiev 2014-06-27 16:16:17 +00:00
parent f0a50ce174
commit 9ef70b55e9
3 changed files with 30 additions and 3 deletions

View File

@ -1,3 +1,21 @@
Meteor.methods
addToCollection: (meetingId, messageObject) ->
addChatToCollection: (meetingId, messageObject) ->
console.log "before -- " + Meteor.Chat.find({meetingId: meetingId}).count()
entry = {
meetingId: meetingId
message: { # or message: messageObject but this is more verbose
chat_type: messageObject.chat_type
message: messageObject.message
to_username: messageObject.to_username
from_tz_offset: messageObject.from_tz_offset
from_color: messageObject.from_color
to_userid: messageObject.to_userid
from_userid: messageObject.from_userid
from_time: messageObject.from_time
from_username: messageObject.from_username
from_lang: messageObject.from_lang
}
}
id = Meteor.Chat.insert(entry)
console.log "added chat id=[#{id}]:#{messageObject.message}. Chat.size is now
#{Meteor.Chat.find({meetingId: meetingId}).count()}"

View File

@ -56,7 +56,7 @@ Meteor.methods
}
id = Meteor.Users.insert(entry)
console.log "added user id=[#{id}]:#{user.name}. Users.size is now #{Meteor.Users.find().count()}"
console.log "added user id=[#{id}]:#{user.name}. Users.size is now #{Meteor.Users.find({meetingId: meetingId}).count()}"
removeUserFromCollection: (meetingId, userId) ->
console.log "----removing " + userId + "from " + meetingId

View File

@ -114,6 +114,15 @@ class Meteor.RedisPubSub
if userId? and meetingId?
Meteor.call("removeUserFromCollection", meetingId, userId)
if message.header?.name is "get_chat_history_reply" and message.payload?.requester_id is "nodeJSapp"
meetingId = message.payload?.meeting_id
for chatMessage in message.payload?.chat_history
Meteor.call("addChatToCollection", meetingId, chatMessage)
if message.header?.name is "send_public_chat_message"
messageObject = message.payload?.message
meetingId = message.payload?.meeting_id
Meteor.call("addChatToCollection", meetingId, messageObject)
publish: (channel, message) ->
console.log "Publishing channel=#{channel}, message=#{JSON.stringify(message)}"