From 7fcc9dcdc2fc6edd7c0cf2f2f152b1c271ffd482 Mon Sep 17 00:00:00 2001 From: Anton Georgiev Date: Fri, 16 May 2014 20:58:20 +0000 Subject: [PATCH 01/12] cleaning up --- .../bbb-html5-client/public/js/models/connection.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/bbb-html5-client/public/js/models/connection.coffee b/client/bbb-html5-client/public/js/models/connection.coffee index e8af8ac4ee..9345395439 100755 --- a/client/bbb-html5-client/public/js/models/connection.coffee +++ b/client/bbb-html5-client/public/js/models/connection.coffee @@ -12,6 +12,7 @@ define [ @socket = null @host = window.location.protocol + "//" + window.location.host + # Grab pieces of info from the URL @authToken = @getUrlVars()["auth_token"] @userId = @getUrlVars()["user_id"] @meetingId = @getUrlVars()["meeting_id"] @@ -29,11 +30,10 @@ define [ console.log("user_id=" + @userId + " auth_token=" + @authToken + " meeting_id=" + @meetingId) unless @socket? console.log "connecting to the socket.io server", @host - @socket = io.connect()# 2 channels for mass message or indiv (or better??) + @socket = io.connect() - #@individual = io.connect() - - #@group = io.connect() + # a1 - just a random + #@socket = io.connect('#{@host}/a1/#{meetingId}/#{userId}') #TODO @_registerEvents() else From fcbf2f8740fb20879a3412756101f5a0c0e8fd6d Mon Sep 17 00:00:00 2001 From: Anton Georgiev Date: Tue, 20 May 2014 18:54:20 +0000 Subject: [PATCH 02/12] working on validate_auth_token_reply - added logs so we can clearly see the validation process/status --- client/bbb-html5-client/lib/clientproxy.coffee | 10 ++++++---- client/bbb-html5-client/lib/controller.coffee | 2 ++ client/bbb-html5-client/lib/redispubsub.coffee | 9 +++++++-- .../public/js/models/connection.coffee | 1 - client/bbb-html5-client/routes/main_router.coffee | 6 +++--- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/client/bbb-html5-client/lib/clientproxy.coffee b/client/bbb-html5-client/lib/clientproxy.coffee index 5c2f90961f..8844db3318 100755 --- a/client/bbb-html5-client/lib/clientproxy.coffee +++ b/client/bbb-html5-client/lib/clientproxy.coffee @@ -29,7 +29,7 @@ module.exports = class ClientProxy # Sends a message in `data` to all the clients that should receive it. sendToClients: (data, callback) -> - log.debug({ data: data }, "Sending to client") + #log.debug({ data: data }, "Sending to client") # the channel can be the user_id (send to one user only) or the meeting_id # (send to everyone in the meeting) @@ -42,8 +42,9 @@ module.exports = class ClientProxy # clients = @io.sockets.clients(channel) # console.log "Found", clients?.length, "clients for the channel", channel - log.debug({ channel: channel, eventName: eventName, message: data, clientCount: clients?.length }, - "Sending message to websocket clients") + #log.debug({ channel: channel, eventName: eventName, message: data, clientCount: clients?.length }, + # "Sending message to websocket clients") + # TODO: if `channel` is undefined, it should not send the message, # instead if is sending to all users @io.sockets.in(channel).emit(eventName, data) @@ -67,7 +68,7 @@ module.exports = class ClientProxy log.error({ message: message }, 'Unknown message name.') _handleLoginMessage: (socket, data) -> - @controller.processAuthMessage data, (err, result) -> + @controller.processAuthMessage(data, (err, result) -> if err? log.debug({ message: result }, "Sending authentication not OK to user and disconnecting socket") sendMessageToClient(socket, result) @@ -84,6 +85,7 @@ module.exports = class ClientProxy log.debug({ message: result }, "Sending authentication OK reply to user") sendMessageToClient(socket, result) + ) sendMessageToClient = (socket, message) -> socket.emit(MESSAGE, message) diff --git a/client/bbb-html5-client/lib/controller.coffee b/client/bbb-html5-client/lib/controller.coffee index 5341f8b233..c6a5adab64 100755 --- a/client/bbb-html5-client/lib/controller.coffee +++ b/client/bbb-html5-client/lib/controller.coffee @@ -20,6 +20,7 @@ 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) @@ -30,6 +31,7 @@ module.exports = class Controller 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 04e56adc2e..6c06f1643d 100644 --- a/client/bbb-html5-client/lib/redispubsub.coffee +++ b/client/bbb-html5-client/lib/redispubsub.coffee @@ -70,13 +70,18 @@ module.exports = class RedisPubSub log.info("Subscribed to #{channel}") _onMessage: (pattern, channel, jsonMsg) => - log.debug({ pattern: pattern, channel: channel, message: jsonMsg}, "Received a message from redis") # TODO: this has to be in a try/catch block, otherwise the server will # crash if the message has a bad format 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 # retrieve the request entry - correlationId = message.header?.reply_to + + #correlationId = message.header?.reply_to + correlationId = message.payload?.reply_to or message.header?.reply_to + console.log "\ncorrelation_id=" + correlationId if correlationId? and @pendingRequests?[correlationId]? entry = @pendingRequests[correlationId] # make sure the message in the timeout isn't triggered by clearing it diff --git a/client/bbb-html5-client/public/js/models/connection.coffee b/client/bbb-html5-client/public/js/models/connection.coffee index 9345395439..b10526696a 100755 --- a/client/bbb-html5-client/public/js/models/connection.coffee +++ b/client/bbb-html5-client/public/js/models/connection.coffee @@ -26,7 +26,6 @@ define [ console.log "tried to disconnect but it's not connected" connect: -> - console.log("user_id=" + @userId + " auth_token=" + @authToken + " meeting_id=" + @meetingId) unless @socket? console.log "connecting to the socket.io server", @host diff --git a/client/bbb-html5-client/routes/main_router.coffee b/client/bbb-html5-client/routes/main_router.coffee index 9dbb832865..02fa3e4e45 100644 --- a/client/bbb-html5-client/routes/main_router.coffee +++ b/client/bbb-html5-client/routes/main_router.coffee @@ -34,9 +34,9 @@ module.exports = class MainRouter authToken = req.query.auth_token console.log "\n\nLANDING PAGE PROVIDED:\n" + - "meeting_id=#{meetingId}\n" + - "user_id=#{userId}\n" + - "auth_token=#{authToken}\n\n" + "meeting_id= #{meetingId}\n" + + "user_id= #{userId}\n" + + "auth_token= #{authToken}\n\n" #go straight into the session view res.render "index", From f66bb034d9d65ff77b15975ad8592816b4ea42af Mon Sep 17 00:00:00 2001 From: Anton Georgiev Date: Wed, 21 May 2014 14:30:51 +0000 Subject: [PATCH 03/12] register user --- .../service/messaging/Constants.java | 3 +- .../messaging/MessageFromJsonConverter.java | 7 ++- .../messaging/RegisterUserMessage.java | 57 ++++++++++++++++++- 3 files changed, 61 insertions(+), 6 deletions(-) diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/Constants.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/Constants.java index a24f659a25..b4d94eab2d 100644 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/Constants.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/Constants.java @@ -84,5 +84,6 @@ public class Constants { public static final String JOINED = "joined"; public static final String X_PERCENT = "x_percent"; public static final String Y_PERCENT = "y_percent"; - public static final String KEEP_ALIVE_ID = "keep_alive_id"; + public static final String KEEP_ALIVE_ID = "keep_alive_id"; + public static final String INTERNAL_USER_ID = "internal_user_id"; } diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/MessageFromJsonConverter.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/MessageFromJsonConverter.java index 98a13888ce..10748e1914 100644 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/MessageFromJsonConverter.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/MessageFromJsonConverter.java @@ -24,14 +24,17 @@ public class MessageFromJsonConverter { return processEndMeetingMessage(payload); case KeepAliveMessage.KEEP_ALIVE_REQUEST: return processKeepAlive(payload); + case RegisterUserMessage.REGISTER_USER: + System.out.println("Registering a user"); + return RegisterUserMessage.fromJson(message); case ValidateAuthTokenMessage.VALIDATE_AUTH_TOKEN: return processValidateAuthTokenMessage(header, payload); case UserConnectedToGlobalAudio.USER_CONNECTED_TO_GLOBAL_AUDIO: System.out.println("Converting message to UserConnectedToGlobalAudio"); - return UserConnectedToGlobalAudio.fromJson(message); + return UserConnectedToGlobalAudio.fromJson(message); case UserDisconnectedFromGlobalAudio.USER_DISCONNECTED_FROM_GLOBAL_AUDIO: System.out.println("Converting message to UserDisconnectedFromGlobalAudio"); - return UserDisconnectedFromGlobalAudio.fromJson(message); + return UserDisconnectedFromGlobalAudio.fromJson(message); } } } diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/RegisterUserMessage.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/RegisterUserMessage.java index 4c7332ae44..9e7dfe5259 100644 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/RegisterUserMessage.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/RegisterUserMessage.java @@ -1,16 +1,20 @@ package org.bigbluebutton.conference.service.messaging; +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + public class RegisterUserMessage implements IMessage { - public static final String REGISTER_USER = "register_user_request"; + public static final String REGISTER_USER = "register_user_request"; public final String VERSION = "0.0.1"; - + public final String meetingID; public final String internalUserId; public final String fullname; public final String role; public final String externUserID; public final String authToken; - + public RegisterUserMessage(String meetingID, String internalUserId, String fullname, String role, String externUserID, String authToken) { this.meetingID = meetingID; this.internalUserId = internalUserId; @@ -19,4 +23,51 @@ public class RegisterUserMessage implements IMessage { this.externUserID = externUserID; this.authToken = authToken; } + + public String toJson() { + HashMap payload = new HashMap(); + + payload.put(Constants.MEETING_ID, meetingID); + payload.put(Constants.INTERNAL_USER_ID, internalUserId); + payload.put(Constants.NAME, fullname); + payload.put(Constants.ROLE, role); + payload.put(Constants.EXT_USER_ID, externUserID); + payload.put(Constants.AUTH_TOKEN, authToken); + + java.util.HashMap header = MessageBuilder.buildHeader(REGISTER_USER, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + public static RegisterUserMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (REGISTER_USER.equals(messageName)) { + if (payload.has(Constants.MEETING_ID) + && payload.has(Constants.NAME) + && payload.has(Constants.ROLE) + && payload.has(Constants.EXT_USER_ID) + && payload.has(Constants.AUTH_TOKEN)) { + + String meetingID = payload.get(Constants.MEETING_ID).getAsString(); + String fullname = payload.get(Constants.NAME).getAsString(); + String role = payload.get(Constants.ROLE).getAsString(); + String externUserID = payload.get(Constants.EXT_USER_ID).getAsString(); + String authToken = payload.get(Constants.AUTH_TOKEN).getAsString(); + + //use externalUserId twice - once for external, once for internal + return new RegisterUserMessage(meetingID, externUserID, fullname, role, externUserID, authToken); + } + } + } + } + System.out.println("Failed to parse RegisterUserMessage"); + return null; + } } From aa85b3343df65c949718a44909c57f0d9bfdf9df Mon Sep 17 00:00:00 2001 From: Anton Georgiev Date: Wed, 21 May 2014 14:31:55 +0000 Subject: [PATCH 04/12] fixing indentations --- .../service/messaging/MessagingConstants.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/MessagingConstants.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/MessagingConstants.java index 8d92757939..3dfb3a9e69 100644 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/MessagingConstants.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/messaging/MessagingConstants.java @@ -1,7 +1,7 @@ /** * BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ * -* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). +* Copyright (c) 2014 BigBlueButton Inc. and by respective authors (see below). * * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free Software @@ -24,22 +24,22 @@ public class MessagingConstants { public static final String FROM_BBB_APPS_PATTERN = FROM_BBB_APPS_CHANNEL + ":*"; public static final String FROM_SYSTEM_CHANNEL = FROM_BBB_APPS_CHANNEL + ":system"; public static final String FROM_MEETING_CHANNEL = FROM_BBB_APPS_CHANNEL + ":meeting"; - public static final String FROM_PRESENTATION_CHANNEL = FROM_BBB_APPS_CHANNEL + ":presentation"; - public static final String FROM_POLLING_CHANNEL = FROM_BBB_APPS_CHANNEL + ":polling"; - public static final String FROM_USERS_CHANNEL = FROM_BBB_APPS_CHANNEL + ":users"; - public static final String FROM_CHAT_CHANNEL = FROM_BBB_APPS_CHANNEL + ":chat"; - public static final String FROM_WHITEBOARD_CHANNEL = FROM_BBB_APPS_CHANNEL + ":whiteboard"; - + public static final String FROM_PRESENTATION_CHANNEL = FROM_BBB_APPS_CHANNEL + ":presentation"; + public static final String FROM_POLLING_CHANNEL = FROM_BBB_APPS_CHANNEL + ":polling"; + public static final String FROM_USERS_CHANNEL = FROM_BBB_APPS_CHANNEL + ":users"; + public static final String FROM_CHAT_CHANNEL = FROM_BBB_APPS_CHANNEL + ":chat"; + public static final String FROM_WHITEBOARD_CHANNEL = FROM_BBB_APPS_CHANNEL + ":whiteboard"; + public static final String TO_BBB_APPS_CHANNEL = "bigbluebutton:to-bbb-apps"; public static final String TO_BBB_APPS_PATTERN = TO_BBB_APPS_CHANNEL + ":*"; public static final String TO_MEETING_CHANNEL = TO_BBB_APPS_CHANNEL + ":meeting"; public static final String TO_SYSTEM_CHANNEL = TO_BBB_APPS_CHANNEL + ":system"; - public static final String TO_PRESENTATION_CHANNEL = TO_BBB_APPS_CHANNEL + ":presentation"; - public static final String TO_POLLING_CHANNEL = TO_BBB_APPS_CHANNEL + ":polling"; - public static final String TO_USERS_CHANNEL = TO_BBB_APPS_CHANNEL + ":users"; - public static final String TO_CHAT_CHANNEL = TO_BBB_APPS_CHANNEL + ":chat"; + public static final String TO_PRESENTATION_CHANNEL = TO_BBB_APPS_CHANNEL + ":presentation"; + public static final String TO_POLLING_CHANNEL = TO_BBB_APPS_CHANNEL + ":polling"; + public static final String TO_USERS_CHANNEL = TO_BBB_APPS_CHANNEL + ":users"; + public static final String TO_CHAT_CHANNEL = TO_BBB_APPS_CHANNEL + ":chat"; + - public static final String DESTROY_MEETING_REQUEST_EVENT = "DestroyMeetingRequestEvent"; public static final String CREATE_MEETING_REQUEST_EVENT = "CreateMeetingRequestEvent"; public static final String END_MEETING_REQUEST_EVENT = "EndMeetingRequestEvent"; @@ -49,7 +49,6 @@ public class MessagingConstants { public static final String USER_JOINED_EVENT = "UserJoinedEvent"; public static final String USER_LEFT_EVENT = "UserLeftEvent"; public static final String USER_STATUS_CHANGE_EVENT = "UserStatusChangeEvent"; - public static final String SEND_POLLS_EVENT = "SendPollsEvent"; + public static final String SEND_POLLS_EVENT = "SendPollsEvent"; public static final String RECORD_STATUS_EVENT = "RecordStatusEvent"; - } From f78264e9dacf4ece407255f7c666221458013d4c Mon Sep 17 00:00:00 2001 From: Anton Georgiev Date: Wed, 21 May 2014 15:57:10 +0000 Subject: [PATCH 05/12] a joining user is displayed in the user list --- client/bbb-html5-client/lib/clientproxy.coffee | 3 +-- .../public/js/models/connection.coffee | 12 +++++++++--- client/bbb-html5-client/routes/main_router.coffee | 8 -------- labs/demos/lib/handlers.coffee | 2 +- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/client/bbb-html5-client/lib/clientproxy.coffee b/client/bbb-html5-client/lib/clientproxy.coffee index 8844db3318..c0c25bbd6b 100755 --- a/client/bbb-html5-client/lib/clientproxy.coffee +++ b/client/bbb-html5-client/lib/clientproxy.coffee @@ -18,13 +18,11 @@ module.exports = class ClientProxy @io = socketio.listen(app) @io.set('log level', 1) @io.sockets.on 'connection', (socket) => - console.log "\n\n\n\n I got a connection message\n\n" log.debug({ client: socket.id }, "Client has connected.") socket.on 'message', (jsonMsg) => log.debug({ message: jsonMsg }, "Received message") @_handleMessage(socket, jsonMsg) socket.on 'disconnect', => - console.log "\n\n\n I got a disconnection message\n\n" @_handleClientDisconnected socket # Sends a message in `data` to all the clients that should receive it. @@ -79,6 +77,7 @@ 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/public/js/models/connection.coffee b/client/bbb-html5-client/public/js/models/connection.coffee index b10526696a..08b946d484 100755 --- a/client/bbb-html5-client/public/js/models/connection.coffee +++ b/client/bbb-html5-client/public/js/models/connection.coffee @@ -16,7 +16,8 @@ define [ @authToken = @getUrlVars()["auth_token"] @userId = @getUrlVars()["user_id"] @meetingId = @getUrlVars()["meeting_id"] - + @username = @getUrlVars()["username"] + console.log "username=" + @username disconnect: -> if @socket? @@ -233,14 +234,19 @@ define [ globals.events.trigger("users:loadUsers", users)### # Received event for a new user - @socket.on "UserJoiningRequest", (message) => #TODO MUST REMOVE WHEN NOT USED ANYMORE + ###@socket.on "UserJoiningRequest", (message) => #TODO MUST REMOVE WHEN NOT USED ANYMORE #console.log "socket on: UserJoiningRequest" #console.log message #eventObject = JSON.parse(message); console.log "message: " + message userid = message.user.metadata.userid #TODO change to new json structure username = message.user.name #TODO change to new json structure - globals.events.trigger("connection:user_join", userid, username) + globals.events.trigger("connection:user_join", userid, username)### + + @socket.on "UserJoined", (userId) => + alert @username + globals.events.trigger("connection:user_join", userId, @username) + # Received event for a new user @socket.on "user_joined_event", (message) => diff --git a/client/bbb-html5-client/routes/main_router.coffee b/client/bbb-html5-client/routes/main_router.coffee index 02fa3e4e45..d5a74c13b0 100644 --- a/client/bbb-html5-client/routes/main_router.coffee +++ b/client/bbb-html5-client/routes/main_router.coffee @@ -41,11 +41,3 @@ module.exports = class MainRouter #go straight into the session view res.render "index", title: config.appName - - - - ###@clientProxy = config.modules.get("ClientProxy") - console.log "\n\n\n\n about to send a request\n" - @clientProxy.sendToClients(message, () -> - console.log "\n\n\n\nSent the request for auth\n\n\n\n" - )### diff --git a/labs/demos/lib/handlers.coffee b/labs/demos/lib/handlers.coffee index 9665961270..7b67b8971f 100644 --- a/labs/demos/lib/handlers.coffee +++ b/labs/demos/lib/handlers.coffee @@ -38,7 +38,7 @@ login = (req, resp) -> "\nauth_token = " + auth_token url = "http://192.168.0.203:3000/html5.client?meeting_id=" + meeting_id + "&user_id=" + - user_id + "&auth_token=" + auth_token + user_id + "&auth_token=" + auth_token + "&username=" + JSON.parse(joinParams.fullName) json = resp.json({ From 28ad6da4634d4412f192b712e27c029d8129c3e6 Mon Sep 17 00:00:00 2001 From: Anton Georgiev Date: Thu, 22 May 2014 15:20:46 +0000 Subject: [PATCH 06/12] fix indents --- .../java/org/bigbluebutton/core/api/IBigBlueButtonInGW.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/core/api/IBigBlueButtonInGW.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/core/api/IBigBlueButtonInGW.java index c9f5f99d7e..1bce859e6c 100755 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/core/api/IBigBlueButtonInGW.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/core/api/IBigBlueButtonInGW.java @@ -30,7 +30,7 @@ public interface IBigBlueButtonInGW { void lowerHand(String meetingId, String userId, String loweredBy); void shareWebcam(String meetingId, String userId, String stream); void unshareWebcam(String meetingId, String userId); - void setUserStatus(String meetingID, String userID, String status, Object value); + void setUserStatus(String meetingID, String userID, String status, Object value); void getUsers(String meetingID, String requesterID); void userLeft(String meetingID, String userID); void userJoin(String meetingID, String userID, String username, String role, String externUserID); @@ -38,8 +38,8 @@ public interface IBigBlueButtonInGW { void assignPresenter(String meetingID, String newPresenterID, String newPresenterName, String assignedBy); void setRecordingStatus(String meetingId, String userId, Boolean recording); void getRecordingStatus(String meetingId, String userId); - void userConnectedToGlobalAudio(String voiceConf, String userid, String name); - void userDisconnectedFromGlobalAudio(String voiceConf, String userid, String name); + void userConnectedToGlobalAudio(String voiceConf, String userid, String name); + void userDisconnectedFromGlobalAudio(String voiceConf, String userid, String name); // Voice void muteAllUsers(String meetingID, String requesterID, Boolean mute); From f9ecc5b9a78505eb0be217bbb0dee599dfbb2c89 Mon Sep 17 00:00:00 2001 From: Anton Georgiev Date: Thu, 22 May 2014 15:22:13 +0000 Subject: [PATCH 07/12] 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", -> From b7b075ce71bb7bf2231f755febaac7fbb43ab3c2 Mon Sep 17 00:00:00 2001 From: Anton Georgiev Date: Thu, 22 May 2014 18:20:21 +0000 Subject: [PATCH 08/12] work on user_joined_event prior to get_users_request --- .../participants/ParticipantsApplication.java | 17 ++++++++++++---- .../participants/ParticipantsListener.java | 15 +++++--------- .../bbb-html5-client/lib/redispubsub.coffee | 20 ++++++++++++++++++- .../public/js/models/connection.coffee | 10 +++++----- 4 files changed, 42 insertions(+), 20 deletions(-) diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsApplication.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsApplication.java index d91b63b43b..f2f2540f97 100755 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsApplication.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsApplication.java @@ -1,7 +1,7 @@ /** * BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ * -* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). +* Copyright (c) 2014 BigBlueButton Inc. and by respective authors (see below). * * This program is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free Software @@ -47,17 +47,26 @@ public class ParticipantsApplication { bbbInGW.setUserStatus(room, userid, status, value); } - public boolean participantLeft(String roomName, String userid) { + public boolean participantJoin(String roomName, String userid) { //is this used?! + log.debug("Participant " + userid + " joining room " + roomName); + System.out.println("\n\n\n\n participantJoin is being used \n\n\n"); + bbbInGW.userJoin(roomName, userid); + return true; + } + + public boolean participantLeft(String roomName, String userid) { //is this used?! log.debug("Participant " + userid + " leaving room " + roomName); + System.out.println("\n\n\n\n participantLeft is being used \n\n\n"); bbbInGW.userLeft(roomName, userid); return true; } - + public boolean registerUser(String roomName, String userid, String username, String role, String externUserID) { + System.out.println("\n\n\n\n registerUser is being used \n\n\n"); bbbInGW.registerUser(roomName, userid, username, role, externUserID, userid); return true; } - + public void assignPresenter(String room, String newPresenterID, String newPresenterName, String assignedBy){ bbbInGW.assignPresenter(room, newPresenterID, newPresenterName, assignedBy); } diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsListener.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsListener.java index dac374e974..e9ccee6786 100644 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsListener.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsListener.java @@ -26,13 +26,12 @@ public class ParticipantsListener implements MessageHandler{ JsonObject obj = (JsonObject) parser.parse(message); JsonObject headerObject = (JsonObject) obj.get("header"); JsonObject payloadObject = (JsonObject) obj.get("payload"); - JsonObject messageObject = (JsonObject)payloadObject.get("message"); String eventName = headerObject.get("name").toString().replace("\"", ""); if(eventName.equalsIgnoreCase("register_user_request") || - eventName.equalsIgnoreCase("participant_left") || //TODO the event name is probably incorrect - eventName.equalsIgnoreCase("participant_join") || //TODO the event name is probably incorrect + eventName.equalsIgnoreCase("user_left_event") || + eventName.equalsIgnoreCase("user_joined_event") || eventName.equalsIgnoreCase("get_users_request") || eventName.equalsIgnoreCase("raise_user_hand_request")){ @@ -44,20 +43,16 @@ public class ParticipantsListener implements MessageHandler{ String role = payloadObject.get("role").toString().replace("\"", ""); String externUserID = payloadObject.get("external_user_id").toString().replace("\"", ""); - } - else if(eventName.equalsIgnoreCase("participant_left")){ //TODO the event name is probably incorrect + else if(eventName.equalsIgnoreCase("user_left_event")){ String userID = payloadObject.get("user_id").toString().replace("\"", ""); bbbInGW.userLeft(roomName, userID); } - else if(eventName.equalsIgnoreCase("participant_join")){ //TODO the event name is probably incorrect + else if(eventName.equalsIgnoreCase("user_joined_event")){ String userID = payloadObject.get("user_id").toString().replace("\"", ""); - String username = payloadObject.get("name").toString().replace("\"", ""); - String role = payloadObject.get("role").toString().replace("\"", ""); - String externUserID = payloadObject.get("external_user_id").toString().replace("\"", ""); - bbbInGW.userJoin(roomName, userID, username, role, externUserID); + bbbInGW.userJoin(roomName, userID); } else if(eventName.equalsIgnoreCase("get_users_request")){ String requesterID = payloadObject.get("requester_id").toString().replace("\"", ""); diff --git a/client/bbb-html5-client/lib/redispubsub.coffee b/client/bbb-html5-client/lib/redispubsub.coffee index 399cf10600..f7759b6bb1 100644 --- a/client/bbb-html5-client/lib/redispubsub.coffee +++ b/client/bbb-html5-client/lib/redispubsub.coffee @@ -98,6 +98,24 @@ module.exports = class RedisPubSub if message.header?.name is 'validate_auth_token_reply' if message.payload?.valid is "true" + #TODO use the message library for these messages. Perhaps put it in Modules?! + + joinMeetingMessage = { + "payload": { + "meeting_id": message.payload.meeting_id + "user_id": message.payload.userid + }, + "header": { + "timestamp": new Date().getTime(), + "reply_to": message.payload.meeting_id + "/" + message.payload.userid + "name": "user_joined_event" + } + } + # the user joins the meeting + + @pubClient.publish(config.redis.channels.toBBBApps.users, JSON.stringify(joinMeetingMessage)) + console.log "just published the joinMeetingMessage in RedisPubSub" + getUsersMessage = { "payload": { "meeting_id": message.payload.meeting_id @@ -111,7 +129,7 @@ module.exports = class RedisPubSub } @pubClient.publish(config.redis.channels.toBBBApps.users, JSON.stringify(getUsersMessage)) - console.log "just published the getUsersMessage from RedisPubSub" + console.log "just published the getUsersMessage in RedisPubSub" if message.header?.name is 'get_users_reply' console.log 'got a reply from bbb-apps: ' + JSON.stringify message diff --git a/client/bbb-html5-client/public/js/models/connection.coffee b/client/bbb-html5-client/public/js/models/connection.coffee index 0683eb889f..c57fe4679c 100755 --- a/client/bbb-html5-client/public/js/models/connection.coffee +++ b/client/bbb-html5-client/public/js/models/connection.coffee @@ -70,13 +70,13 @@ define [ message = { "payload": { - "auth_token": @authToken - "userid": @userId - "meeting_id": @meetingId + "auth_token": @authToken + "userid": @userId + "meeting_id": @meetingId }, "header": { - "timestamp": new Date().getTime() - "name": "validate_auth_token" + "timestamp": new Date().getTime() + "name": "validate_auth_token" } } From f676657b3b953b25aa3e2a839bffc0a67294d596 Mon Sep 17 00:00:00 2001 From: Anton Georgiev Date: Thu, 22 May 2014 19:25:00 +0000 Subject: [PATCH 09/12] displays the users in the UI userlist --- client/bbb-html5-client/lib/controller.coffee | 2 +- client/bbb-html5-client/lib/redispubsub.coffee | 8 ++++---- .../bbb-html5-client/public/js/models/connection.coffee | 6 +++++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/client/bbb-html5-client/lib/controller.coffee b/client/bbb-html5-client/lib/controller.coffee index 9584c8a47d..5341f8b233 100755 --- a/client/bbb-html5-client/lib/controller.coffee +++ b/client/bbb-html5-client/lib/controller.coffee @@ -24,7 +24,7 @@ module.exports = class Controller log.error({ reason: err, result: result, original: data }, "Authentication failure") callback(err, null) else - if result.payload?.valid #is 'true' + if result.payload?.valid log.info({ result: result }, "Authentication successful") callback(null, result) else diff --git a/client/bbb-html5-client/lib/redispubsub.coffee b/client/bbb-html5-client/lib/redispubsub.coffee index f7759b6bb1..ede22d3a1a 100644 --- a/client/bbb-html5-client/lib/redispubsub.coffee +++ b/client/bbb-html5-client/lib/redispubsub.coffee @@ -73,6 +73,7 @@ module.exports = class RedisPubSub # TODO: this has to be in a try/catch block, otherwise the server will # crash if the message has a bad format 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 "=="+JSON.stringify message @@ -93,7 +94,7 @@ module.exports = class RedisPubSub topic: entry.replyTo.topic data: message else - sendToController(message) + #sendToController(message) if message.header?.name is 'validate_auth_token_reply' if message.payload?.valid is "true" @@ -131,9 +132,8 @@ module.exports = class RedisPubSub @pubClient.publish(config.redis.channels.toBBBApps.users, JSON.stringify(getUsersMessage)) console.log "just published the getUsersMessage in RedisPubSub" - if message.header?.name is 'get_users_reply' - console.log 'got a reply from bbb-apps: ' + JSON.stringify message - + else if message.header?.name is 'get_users_reply' + console.log 'got a reply from bbb-apps' sendToController(message) sendToController = (message) -> diff --git a/client/bbb-html5-client/public/js/models/connection.coffee b/client/bbb-html5-client/public/js/models/connection.coffee index c57fe4679c..5ce643aa69 100755 --- a/client/bbb-html5-client/public/js/models/connection.coffee +++ b/client/bbb-html5-client/public/js/models/connection.coffee @@ -85,7 +85,11 @@ define [ @socket.emit "message", message @socket.on "get_users_reply", (message) => - alert 'will now populate some users' + JSON.stringify message + users = [] + for user in message.payload?.users + users.push user + + globals.events.trigger("connection:load_users", users) # Received event to logout yourself @socket.on "logout", -> From 3b6331997f6d79a4be1388f95ba804e693621da1 Mon Sep 17 00:00:00 2001 From: Anton Georgiev Date: Thu, 22 May 2014 21:50:51 +0000 Subject: [PATCH 10/12] cleaning up --- .../participants/ParticipantsListener.java | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsListener.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsListener.java index e9ccee6786..b10a9f835e 100644 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsListener.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/participants/ParticipantsListener.java @@ -70,45 +70,6 @@ public class ParticipantsListener implements MessageHandler{ bbbInGW.lowerHand(roomName, userID, requesterID); } } - - /* //This code was written to support user_joined_event and user_left_event from - //https://github.com/bigbluebutton/bigbluebutton/blob/bbb-apps-wip/server/bbb-apps/src/test/scala/org/bigbluebutton/endpoint/JsonMessagesFixtures.scala - - JsonParser parser = new JsonParser(); - JsonObject obj = (JsonObject) parser.parse(message); - JsonObject header = (JsonObject) obj.get("header"); - //System.out.println ("header="+header); - JsonObject payload = (JsonObject) obj.get("payload"); - - String eventName = header.get("name").toString(); - eventName = eventName.replace("\"", "");//strip off quotations - System.out.println("eventName="+eventName); - - JsonObject user = (JsonObject) payload.get("user"); - JsonObject meeting = (JsonObject) payload.get("meeting"); - - String meetingid = meeting.get("id").toString().replace("\"", ""); - String userID = user.get("id").toString().replace("\"", ""); - String username = user.get("name").toString().replace("\"", ""); - String role = user.get("role").toString().replace("\"", ""); - String externuserID = user.get("external_id").toString().replace("\"", "");*/ - /* - if(eventName.equalsIgnoreCase("user_joined_event")) //put this string into a constants file - { - System.out.println("I'm in the case for joined_event" ); - System.out.println("\nmeetingid="+meetingid+", "+"userID = "+userID+", username="+username+ - ", role="+role+"external_id="+externuserID); - - bbbGW.userJoin(meetingid, userID, username, role, externuserID); - } - else if(eventName.equalsIgnoreCase("user_left_event")) //put this string into a constants file - { - System.out.println("I'm in the case for left_event" ); - System.out.println("\nmeetingid="+meetingid+", "+"userID = "+userID); - - bbbGW.userLeft(meetingid, userID); - } - */ } } } From 54ffccf8ac915fc454a73e1df31d787f81b3bac4 Mon Sep 17 00:00:00 2001 From: Anton Georgiev Date: Thu, 22 May 2014 21:52:36 +0000 Subject: [PATCH 11/12] get_chat_history, get_chat_history_reply. The history should be displaying properly but I should first fix sending a chat message. Otherwise the history will remain empty --- .../service/chat/ChatMessageListener.java | 94 +++++++++---------- client/bbb-html5-client/config.coffee | 1 + .../bbb-html5-client/lib/clientproxy.coffee | 2 - .../bbb-html5-client/lib/redispubsub.coffee | 44 ++++++--- .../public/js/models/connection.coffee | 4 + 5 files changed, 85 insertions(+), 60 deletions(-) diff --git a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/chat/ChatMessageListener.java b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/chat/ChatMessageListener.java index 79faa4d8b8..f7637cc9f8 100755 --- a/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/chat/ChatMessageListener.java +++ b/bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/chat/ChatMessageListener.java @@ -1,7 +1,5 @@ - package org.bigbluebutton.conference.service.chat; - import org.bigbluebutton.conference.service.messaging.MessagingConstants; import org.bigbluebutton.conference.service.messaging.redis.MessageHandler; import com.google.gson.JsonParser; @@ -19,11 +17,10 @@ public class ChatMessageListener implements MessageHandler{ public void setBigBlueButtonInGW(IBigBlueButtonInGW bbbGW) { this.bbbGW = bbbGW; } - + @Override public void handleMessage(String pattern, String channel, String message) { if (channel.equalsIgnoreCase(MessagingConstants.TO_CHAT_CHANNEL)) { - System.out.println("AntonChannel=(chatlistener)" + channel); JsonParser parser = new JsonParser(); JsonObject obj = (JsonObject) parser.parse(message); @@ -34,57 +31,60 @@ public class ChatMessageListener implements MessageHandler{ String eventName = headerObject.get("name").toString(); eventName = eventName.replace("\"", ""); - if (eventName.equalsIgnoreCase("public_chat_message_event") || - eventName.equalsIgnoreCase("send_public_chat_message") || + if (eventName.equalsIgnoreCase("public_chat_message_event") || + //eventName.equalsIgnoreCase("send_public_chat_message") || eventName.equalsIgnoreCase("private_chat_message_event") || - eventName.equalsIgnoreCase("send_private_chat_message")){ + //eventName.equalsIgnoreCase("send_private_chat_message") || + eventName.equalsIgnoreCase("get_chat_history")){ String meetingID = payloadObject.get("meeting_id").toString().replace("\"", ""); String requesterID = payloadObject.get("requester_id").toString().replace("\"", ""); - String chatType = messageObject.get("chatType").toString().replace("\"", ""); - String fromUserID = messageObject.get("fromUserID").toString().replace("\"", ""); - String fromUsername = messageObject.get("fromUsername").toString().replace("\"", ""); - String fromColor = messageObject.get("fromColor").toString().replace("\"", ""); - String fromTime = messageObject.get("fromTime").toString().replace("\"", ""); - String fromTimezoneOffset = messageObject.get("fromTimezoneOffset").toString().replace("\"", ""); - String fromLang = messageObject.get("fromLang").toString().replace("\"", ""); - String toUserID = messageObject.get("toUserID").toString().replace("\"", ""); - String toUsername = messageObject.get("toUsername").toString().replace("\"", ""); - String chatText = messageObject.get("message").toString().replace("\"", ""); - Map map = new HashMap(); - map.put(ChatKeyUtil.CHAT_TYPE, chatType); - map.put(ChatKeyUtil.FROM_USERID, fromUserID); - map.put(ChatKeyUtil.FROM_USERNAME, fromUsername); - map.put(ChatKeyUtil.FROM_COLOR, fromColor); - map.put(ChatKeyUtil.FROM_TIME, fromTime); - map.put(ChatKeyUtil.FROM_TZ_OFFSET, fromTimezoneOffset); - map.put(ChatKeyUtil.FROM_LANG, fromLang); - map.put(ChatKeyUtil.TO_USERID, toUserID); - map.put(ChatKeyUtil.TO_USERNAME, toUsername); - map.put(ChatKeyUtil.MESSAGE, chatText); - - //public message - if(eventName.equalsIgnoreCase("public_chat_message_event") || eventName.equalsIgnoreCase("send_public_chat_message")) //put this string into a constants file - { - System.out.println("I'm in the case for a public chat message" ); - - bbbGW.sendPublicMessage(meetingID, requesterID, map); - - } - //private message - else if(eventName.equalsIgnoreCase("private_chat_message_event") || eventName.equalsIgnoreCase("send_private_chat_message")) //put this string into a constants file - { - System.out.println("I'm in the case for a private chat message" ); - - bbbGW.sendPrivateMessage(meetingID, requesterID, map); //TODO not tested yet - } //case getChatHistory - else if(eventName.equalsIgnoreCase("get_chat_history")) { - System.out.println("I'm in the case for a requesting chat history" ); - String replyTo = meetingID + "/" + requesterID; + if(eventName.equalsIgnoreCase("get_chat_history")) { + String replyTo = meetingID + "/" + requesterID; bbbGW.getChatHistory(meetingID, requesterID, replyTo); } + else { + String chatType = messageObject.get("chatType").toString().replace("\"", ""); + String fromUserID = messageObject.get("fromUserID").toString().replace("\"", ""); + String fromUsername = messageObject.get("fromUsername").toString().replace("\"", ""); + String fromColor = messageObject.get("fromColor").toString().replace("\"", ""); + String fromTime = messageObject.get("fromTime").toString().replace("\"", ""); + String fromTimezoneOffset = messageObject.get("fromTimezoneOffset").toString().replace("\"", ""); + String fromLang = messageObject.get("fromLang").toString().replace("\"", ""); + String toUserID = messageObject.get("toUserID").toString().replace("\"", ""); + String toUsername = messageObject.get("toUsername").toString().replace("\"", ""); + String chatText = messageObject.get("message").toString().replace("\"", ""); + + Map map = new HashMap(); + map.put(ChatKeyUtil.CHAT_TYPE, chatType); + map.put(ChatKeyUtil.FROM_USERID, fromUserID); + map.put(ChatKeyUtil.FROM_USERNAME, fromUsername); + map.put(ChatKeyUtil.FROM_COLOR, fromColor); + map.put(ChatKeyUtil.FROM_TIME, fromTime); + map.put(ChatKeyUtil.FROM_TZ_OFFSET, fromTimezoneOffset); + map.put(ChatKeyUtil.FROM_LANG, fromLang); + map.put(ChatKeyUtil.TO_USERID, toUserID); + map.put(ChatKeyUtil.TO_USERNAME, toUsername); + map.put(ChatKeyUtil.MESSAGE, chatText); + + //public message + if(eventName.equalsIgnoreCase("public_chat_message_event") || eventName.equalsIgnoreCase("send_public_chat_message")) //put this string into a constants file + { + System.out.println("I'm in the case for a public chat message" ); + + bbbGW.sendPublicMessage(meetingID, requesterID, map); + } + + //private message + else if(eventName.equalsIgnoreCase("private_chat_message_event") || eventName.equalsIgnoreCase("send_private_chat_message")) //put this string into a constants file + { + System.out.println("I'm in the case for a private chat message" ); + + bbbGW.sendPrivateMessage(meetingID, requesterID, map); //TODO not tested yet + } + } } } } diff --git a/client/bbb-html5-client/config.coffee b/client/bbb-html5-client/config.coffee index 73c42360a1..416d181cfc 100755 --- a/client/bbb-html5-client/config.coffee +++ b/client/bbb-html5-client/config.coffee @@ -30,6 +30,7 @@ config.redis.channels = {} 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.chat = "bigbluebutton:to-bbb-apps:chat" config.redis.channels.toBBBApps.meeting = "bigbluebutton:to-bbb-apps:meeting" config.redis.channels.toBBBApps.users = "bigbluebutton:to-bbb-apps:users" config.redis.internalChannels = {} diff --git a/client/bbb-html5-client/lib/clientproxy.coffee b/client/bbb-html5-client/lib/clientproxy.coffee index 92c9180081..f054a192b9 100755 --- a/client/bbb-html5-client/lib/clientproxy.coffee +++ b/client/bbb-html5-client/lib/clientproxy.coffee @@ -62,8 +62,6 @@ 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.') diff --git a/client/bbb-html5-client/lib/redispubsub.coffee b/client/bbb-html5-client/lib/redispubsub.coffee index ede22d3a1a..56d0496315 100644 --- a/client/bbb-html5-client/lib/redispubsub.coffee +++ b/client/bbb-html5-client/lib/redispubsub.coffee @@ -103,13 +103,13 @@ module.exports = class RedisPubSub joinMeetingMessage = { "payload": { - "meeting_id": message.payload.meeting_id - "user_id": message.payload.userid + "meeting_id": message.payload.meeting_id + "user_id": message.payload.userid }, "header": { - "timestamp": new Date().getTime(), - "reply_to": message.payload.meeting_id + "/" + message.payload.userid - "name": "user_joined_event" + "timestamp": new Date().getTime() + "reply_to": message.payload.meeting_id + "/" + message.payload.userid + "name": "user_joined_event" } } # the user joins the meeting @@ -117,23 +117,45 @@ module.exports = class RedisPubSub @pubClient.publish(config.redis.channels.toBBBApps.users, JSON.stringify(joinMeetingMessage)) console.log "just published the joinMeetingMessage in RedisPubSub" + #get the list of users in the meeting getUsersMessage = { "payload": { - "meeting_id": message.payload.meeting_id - "requester_id": message.payload.userid + "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" + "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 in RedisPubSub" + #get the chat history + getChatHistory = { + "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_chat_history" + } + } + + @pubClient.publish(config.redis.channels.toBBBApps.chat, JSON.stringify(getChatHistory)) + console.log "just published the getChatHistory in RedisPubSub" + + else if message.header?.name is 'get_users_reply' - console.log 'got a reply from bbb-apps' + console.log 'got a reply from bbb-apps for get users' + sendToController(message) + + else if message.header?.name is 'get_chat_history_reply' + console.log 'got a reply from bbb-apps for chat history' sendToController(message) sendToController = (message) -> diff --git a/client/bbb-html5-client/public/js/models/connection.coffee b/client/bbb-html5-client/public/js/models/connection.coffee index 5ce643aa69..10691ff922 100755 --- a/client/bbb-html5-client/public/js/models/connection.coffee +++ b/client/bbb-html5-client/public/js/models/connection.coffee @@ -91,6 +91,10 @@ define [ globals.events.trigger("connection:load_users", users) + @socket.on "get_chat_history_reply", (message) -> + alert 'got these messages:' + JSON.stringify message + globals.events.trigger("connection:all_messages", message) + # Received event to logout yourself @socket.on "logout", -> console.log "socket on: logout" From 06fa37e6851fd9bfa7ca4ddf3b86f9daa7c2ea72 Mon Sep 17 00:00:00 2001 From: Anton Georgiev Date: Fri, 23 May 2014 14:16:56 +0000 Subject: [PATCH 12/12] cleaning up --- .../public/js/models/connection.coffee | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/client/bbb-html5-client/public/js/models/connection.coffee b/client/bbb-html5-client/public/js/models/connection.coffee index 10691ff922..7d0bce2ee0 100755 --- a/client/bbb-html5-client/public/js/models/connection.coffee +++ b/client/bbb-html5-client/public/js/models/connection.coffee @@ -39,9 +39,6 @@ define [ else console.log "tried to connect but it's already connected" - # authenticate: (userId, meetingId) -> - # @socket.emit "message", message - emit: (data) -> if @isConnected() @socket.emit("message", data) @@ -237,27 +234,6 @@ define [ console.log "socket on: user list change" globals.events.trigger("connection:user_list_change", users) - # TODO: event name with spaces is bad - ###@socket.on "loadUsers", (loadUsersEventObject) => - users = loadUsersEventObject.usernames - console.log "socket on: loadUsers" + loadUsersEventObject - globals.events.trigger("users:loadUsers", users)### - - # Received event for a new user - ###@socket.on "UserJoiningRequest", (message) => #TODO MUST REMOVE WHEN NOT USED ANYMORE - #console.log "socket on: UserJoiningRequest" - #console.log message - #eventObject = JSON.parse(message); - console.log "message: " + message - userid = message.user.metadata.userid #TODO change to new json structure - username = message.user.name #TODO change to new json structure - globals.events.trigger("connection:user_join", userid, username)### - - @socket.on "UserJoined", (userId) => - alert @username - globals.events.trigger("connection:user_join", userId, @username) - - # Received event for a new user @socket.on "user_joined_event", (message) => console.log "message: " + message @@ -271,11 +247,6 @@ define [ userid = message.payload.user.id globals.events.trigger("connection:user_left", userid) - # Received event when a user leave - @socket.on "user leave", (userid) => - console.log "socket on: user leave" - globals.events.trigger("connection:user_leave", userid) - # Received event to set the presenter to a user # @param {string} userID publicID of the user that is being set as the current presenter @socket.on "setPresenter", (userid) =>