diff --git a/labs/meteor-client/collections/chat.coffee b/labs/meteor-client/collections/chat.coffee index 5f29c7294f..56bcb254d5 100644 --- a/labs/meteor-client/collections/chat.coffee +++ b/labs/meteor-client/collections/chat.coffee @@ -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()}" diff --git a/labs/meteor-client/collections/users.coffee b/labs/meteor-client/collections/users.coffee index 67c87fac85..f359421e04 100755 --- a/labs/meteor-client/collections/users.coffee +++ b/labs/meteor-client/collections/users.coffee @@ -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 diff --git a/labs/meteor-client/server/redispubsub.coffee b/labs/meteor-client/server/redispubsub.coffee index 6baec2fe03..0440865c13 100644 --- a/labs/meteor-client/server/redispubsub.coffee +++ b/labs/meteor-client/server/redispubsub.coffee @@ -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)}"