bigbluebutton-Github/labs/meteor-client/server/redispubsub.coffee

38 lines
1.3 KiB
CoffeeScript
Raw Normal View History

2014-06-12 03:26:46 +08:00
class Meteor.RedisPubSub
constructor: () ->
console.log "constructor RedisPubSub"
2014-06-12 03:26:46 +08:00
@pubClient = redis.createClient()
@subClient = redis.createClient()
2014-06-12 03:26:46 +08:00
@subClient.on "psubscribe", (channel, count) =>
#log.info
console.log("Subscribed to #{channel}")
2014-06-12 03:26:46 +08:00
@subClient.on "pmessage", (pattern, channel, jsonMsg) =>
console.log "GOT MESSAGE:" + jsonMsg
2014-06-12 03:26:46 +08:00
#log.info
console.log("RPC: Subscribing message on channel: #{Meteor.config.redis.channels.fromBBBApps}")
@subClient.psubscribe(Meteor.config.redis.channels.fromBBBApps)
2014-06-12 03:26:46 +08:00
# Construct and send a message to bbb-web to validate the user
sendValidateToken: (meetingId, userId, authToken) ->
console.log "\n\n i am sending a validate_auth_token with " + userId + "" + meetingId
2014-06-14 02:01:32 +08:00
message = {
"payload": {
"auth_token": authToken
"userid": userId
"meeting_id": meetingId
},
"header": {
"timestamp": new Date().getTime()
"reply_to": meetingId + "/" + userId
2014-06-14 02:01:32 +08:00
"name": "validate_auth_token"
}
}
if authToken? and userId? and meetingId?
@pubClient.publish(Meteor.config.redis.channels.toBBBApps.meeting, JSON.stringify(message))
else
console.log "did not have enough information to send a validate_auth_token message"