From f9ecc5b9a78505eb0be217bbb0dee599dfbb2c89 Mon Sep 17 00:00:00 2001 From: Anton Georgiev Date: Thu, 22 May 2014 15:22:13 +0000 Subject: [PATCH] get_users_request + reply ... the array of users is empty for now, I wonder if it will contain users if my user is not the only one in the meeting --- client/bbb-html5-client/config.coffee | 1 + .../bbb-html5-client/lib/clientproxy.coffee | 5 ++-- client/bbb-html5-client/lib/controller.coffee | 4 +-- .../bbb-html5-client/lib/redispubsub.coffee | 27 +++++++++++++++++-- .../public/js/models/connection.coffee | 8 +++--- 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/client/bbb-html5-client/config.coffee b/client/bbb-html5-client/config.coffee index f11eb9c02b..73c42360a1 100755 --- a/client/bbb-html5-client/config.coffee +++ b/client/bbb-html5-client/config.coffee @@ -31,6 +31,7 @@ config.redis.channels.fromBBBApps = "bigbluebutton:from-bbb-apps:*" config.redis.channels.toBBBApps = {} config.redis.channels.toBBBApps.pattern = "bigbluebutton:to-bbb-apps:*" config.redis.channels.toBBBApps.meeting = "bigbluebutton:to-bbb-apps:meeting" +config.redis.channels.toBBBApps.users = "bigbluebutton:to-bbb-apps:users" config.redis.internalChannels = {} config.redis.internalChannels.receive = "html5-receive" config.redis.internalChannels.reply = "html5-reply" diff --git a/client/bbb-html5-client/lib/clientproxy.coffee b/client/bbb-html5-client/lib/clientproxy.coffee index c0c25bbd6b..92c9180081 100755 --- a/client/bbb-html5-client/lib/clientproxy.coffee +++ b/client/bbb-html5-client/lib/clientproxy.coffee @@ -20,7 +20,7 @@ module.exports = class ClientProxy @io.sockets.on 'connection', (socket) => log.debug({ client: socket.id }, "Client has connected.") socket.on 'message', (jsonMsg) => - log.debug({ message: jsonMsg }, "Received message") + log.debug({ message: jsonMsg }, "Received message") # TODO to check whether only 'message' works or 'djhkwa' too @_handleMessage(socket, jsonMsg) socket.on 'disconnect', => @_handleClientDisconnected socket @@ -62,6 +62,8 @@ module.exports = class ClientProxy switch message.header.name when 'validate_auth_token' @_handleLoginMessage socket, message + when 'get_users_reply' + sendMessageToClient socket, message else log.error({ message: message }, 'Unknown message name.') @@ -77,7 +79,6 @@ module.exports = class ClientProxy socket.join(result.payload.user_id) socket.join(result.payload.meeting_id) - socket.emit("UserJoined", result.payload.user_id) # assign the userId to this socket. This way we can # locate this socket using the userId. socket.userId = result?.payload?.user_id diff --git a/client/bbb-html5-client/lib/controller.coffee b/client/bbb-html5-client/lib/controller.coffee index c6a5adab64..9584c8a47d 100755 --- a/client/bbb-html5-client/lib/controller.coffee +++ b/client/bbb-html5-client/lib/controller.coffee @@ -20,18 +20,16 @@ module.exports = class Controller processAuthMessage: (data, callback) -> log.info({ data: data }, "Sending an authentication request and waiting for reply") @messageBus.sendAndWaitForReply data, (err, result) -> - console.log "\n I am waiting for a reply" if err? log.error({ reason: err, result: result, original: data }, "Authentication failure") callback(err, null) else - if result.payload?.valid + if result.payload?.valid #is 'true' log.info({ result: result }, "Authentication successful") callback(null, result) else log.info({ result: result }, "Authentication failure") callback(new Error("Authentication failure"), null) - console.log "\n I am no longer waiting for a reply" # processEndMessage: (data, callback) -> # @clientProxy.endMeeting() diff --git a/client/bbb-html5-client/lib/redispubsub.coffee b/client/bbb-html5-client/lib/redispubsub.coffee index 6c06f1643d..399cf10600 100644 --- a/client/bbb-html5-client/lib/redispubsub.coffee +++ b/client/bbb-html5-client/lib/redispubsub.coffee @@ -58,7 +58,7 @@ module.exports = class RedisPubSub # put the entry in the hash so we can match the response later @pendingRequests[correlationId] = entry message.header.reply_to = correlationId - console.log("\n\n\n\n\nmessage=" + JSON.stringify(message) + "\n\n\n") + console.log("\n\nmessage=" + JSON.stringify(message) + "\n\n") log.info({ message: message, channel: config.redis.channels.toBBBApps.meeting}, "Publishing a message") @pubClient.publish(config.redis.channels.toBBBApps.meeting, JSON.stringify(message)) @@ -75,7 +75,7 @@ module.exports = class RedisPubSub message = JSON.parse(jsonMsg) unless message.header?.name is "keep_alive_reply" #temporarily stop logging the keep_alive_reply message log.debug({ pattern: pattern, channel: channel, message: message}, "Received a message from redis") - console.log "=="+message.header?.name + console.log "=="+JSON.stringify message # retrieve the request entry @@ -95,6 +95,29 @@ module.exports = class RedisPubSub else sendToController(message) + if message.header?.name is 'validate_auth_token_reply' + if message.payload?.valid is "true" + + getUsersMessage = { + "payload": { + "meeting_id": message.payload.meeting_id + "requester_id": message.payload.userid + }, + "header": { + "timestamp": new Date().getTime(), + "reply_to": message.payload.meeting_id + "/" + message.payload.userid + "name": "get_users_request" + } + } + + @pubClient.publish(config.redis.channels.toBBBApps.users, JSON.stringify(getUsersMessage)) + console.log "just published the getUsersMessage from RedisPubSub" + + if message.header?.name is 'get_users_reply' + console.log 'got a reply from bbb-apps: ' + JSON.stringify message + + sendToController(message) + sendToController = (message) -> postal.publish channel: config.redis.internalChannels.receive diff --git a/client/bbb-html5-client/public/js/models/connection.coffee b/client/bbb-html5-client/public/js/models/connection.coffee index 08b946d484..0683eb889f 100755 --- a/client/bbb-html5-client/public/js/models/connection.coffee +++ b/client/bbb-html5-client/public/js/models/connection.coffee @@ -80,10 +80,12 @@ define [ } } - validFields = @authToken? and @userId? and @meetingId? + #emit the validate_auth_token json message if the fields have been populated + if @authToken? and @userId? and @meetingId? + @socket.emit "message", message - #emit the validate token json message - @socket.emit "message", message if validFields + @socket.on "get_users_reply", (message) => + alert 'will now populate some users' + JSON.stringify message # Received event to logout yourself @socket.on "logout", ->