Search in sources :

Example 1 with IBigBlueButtonMessage

use of org.bigbluebutton.common.messages.IBigBlueButtonMessage in project bigbluebutton by bigbluebutton.

the class BbbAppsIsKeepAliveHandler method processBbbAppsIsAliveMessage.

private void processBbbAppsIsAliveMessage(String json) {
    IBigBlueButtonMessage msg = decoder.decodeMessage(json);
    if (msg != null) {
        PubSubPongMessage m = (PubSubPongMessage) msg;
        monitorService.handleKeepAliveMessage(m.payload.system, m.payload.timestamp);
    }
}
Also used : PubSubPongMessage(org.bigbluebutton.common.messages.PubSubPongMessage) IBigBlueButtonMessage(org.bigbluebutton.common.messages.IBigBlueButtonMessage)

Example 2 with IBigBlueButtonMessage

use of org.bigbluebutton.common.messages.IBigBlueButtonMessage in project bigbluebutton by bigbluebutton.

the class MeetingMessageHandler method handleMessage.

public void handleMessage(String pattern, String channel, String message) {
    JsonParser parser = new JsonParser();
    JsonObject obj = (JsonObject) parser.parse(message);
    if (channel.equalsIgnoreCase(MessagingConstants.FROM_MEETING_CHANNEL)) {
        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 (MessagingConstants.MEETING_STARTED_EVENT.equalsIgnoreCase(messageName)) {
                    String meetingId = payload.get("meeting_id").getAsString();
                    for (MessageListener listener : listeners) {
                        listener.handle(new MeetingStarted(meetingId));
                    }
                } else if (MessagingConstants.MEETING_ENDED_EVENT.equalsIgnoreCase(messageName)) {
                    String meetingId = payload.get("meeting_id").getAsString();
                    for (MessageListener listener : listeners) {
                        listener.handle(new MeetingEnded(meetingId));
                    }
                } else if (MessagingConstants.MEETING_DESTROYED_EVENT.equalsIgnoreCase(messageName)) {
                    String meetingId = payload.get("meeting_id").getAsString();
                    log.info("Received a meeting destroyed message for meeting id=[{}]", meetingId);
                    for (MessageListener listener : listeners) {
                        listener.handle(new MeetingDestroyed(meetingId));
                    }
                } else if (CreateBreakoutRoomRequest.NAME.equals(messageName)) {
                    CreateBreakoutRoomRequest msg = new Gson().fromJson(message, CreateBreakoutRoomRequest.class);
                    for (MessageListener listener : listeners) {
                        listener.handle(new CreateBreakoutRoom(msg.payload.breakoutMeetingId, msg.payload.parentMeetingId, msg.payload.name, msg.payload.sequence, msg.payload.voiceConfId, msg.payload.viewerPassword, msg.payload.moderatorPassword, msg.payload.durationInMinutes, msg.payload.sourcePresentationId, msg.payload.sourcePresentationSlide, msg.payload.record));
                    }
                } else if (EndBreakoutRoomRequest.NAME.equals(messageName)) {
                    EndBreakoutRoomRequest msg = new Gson().fromJson(message, EndBreakoutRoomRequest.class);
                    log.info("Received end breakout room request message for breakout meeting id=[{}]", msg.payload.meetingId);
                    for (MessageListener listener : listeners) {
                        listener.handle(new EndBreakoutRoom(msg.payload.meetingId));
                    }
                }
            }
        }
    } else if (channel.equalsIgnoreCase(MessagingConstants.FROM_SYSTEM_CHANNEL)) {
        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();
                IMessage rxMsg = null;
                if (PubSubPongMessage.PUBSUB_PONG.equals(messageName)) {
                    IBigBlueButtonMessage msg = decoder.decodeMessage(message);
                    if (msg != null) {
                        PubSubPongMessage m = (PubSubPongMessage) msg;
                        rxMsg = new KeepAliveReply(m.payload.system, m.payload.timestamp);
                    }
                }
                if (rxMsg != null) {
                    for (MessageListener listener : listeners) {
                        listener.handle(rxMsg);
                    }
                }
            }
        }
    } else if (channel.equalsIgnoreCase(MessagingConstants.FROM_USERS_CHANNEL)) {
        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 (MessagingConstants.USER_JOINED_EVENT.equalsIgnoreCase(messageName)) {
                    String meetingId = payload.get("meeting_id").getAsString();
                    JsonObject user = (JsonObject) payload.get("user");
                    String userid = user.get("userid").getAsString();
                    String externuserid = user.get("extern_userid").getAsString();
                    String username = user.get("name").getAsString();
                    String role = user.get("role").getAsString();
                    String avatarURL = user.get("avatarURL").getAsString();
                    for (MessageListener listener : listeners) {
                        listener.handle(new UserJoined(meetingId, userid, externuserid, username, role, avatarURL));
                    }
                } else if (MessagingConstants.USER_STATUS_CHANGE_EVENT.equalsIgnoreCase(messageName)) {
                    String meetingId = payload.get("meeting_id").getAsString();
                    String userid = payload.get("userid").getAsString();
                    String status = payload.get("status").getAsString();
                    String value = payload.get("value").getAsString();
                    for (MessageListener listener : listeners) {
                        listener.handle(new UserStatusChanged(meetingId, userid, status, value));
                    }
                } else if (MessagingConstants.USER_LEFT_EVENT.equalsIgnoreCase(messageName)) {
                    String meetingId = payload.get("meeting_id").getAsString();
                    JsonObject user = (JsonObject) payload.get("user");
                    String userid = user.get("userid").getAsString();
                    for (MessageListener listener : listeners) {
                        listener.handle(new UserLeft(meetingId, userid));
                    }
                } else if (MessagingConstants.USER_JOINED_VOICE_EVENT.equalsIgnoreCase(messageName)) {
                    String meetingId = payload.get("meeting_id").getAsString();
                    JsonObject user = (JsonObject) payload.get("user");
                    String userid = user.get("userid").getAsString();
                    for (MessageListener listener : listeners) {
                        listener.handle(new UserJoinedVoice(meetingId, userid));
                    }
                } else if (MessagingConstants.USER_LEFT_VOICE_EVENT.equalsIgnoreCase(messageName)) {
                    String meetingId = payload.get("meeting_id").getAsString();
                    JsonObject user = (JsonObject) payload.get("user");
                    String userid = user.get("userid").getAsString();
                    for (MessageListener listener : listeners) {
                        listener.handle(new UserLeftVoice(meetingId, userid));
                    }
                } else if (MessagingConstants.USER_LISTEN_ONLY_EVENT.equalsIgnoreCase(messageName)) {
                    String meetingId = payload.get("meeting_id").getAsString();
                    String userid = payload.get("userid").getAsString();
                    Boolean listenOnly = payload.get("listen_only").getAsBoolean();
                    for (MessageListener listener : listeners) {
                        listener.handle(new UserListeningOnly(meetingId, userid, listenOnly));
                    }
                } else if (MessagingConstants.USER_SHARE_WEBCAM_EVENT.equalsIgnoreCase(messageName)) {
                    String meetingId = payload.get("meeting_id").getAsString();
                    String userid = payload.get("userid").getAsString();
                    String stream = payload.get("stream").getAsString();
                    for (MessageListener listener : listeners) {
                        listener.handle(new UserSharedWebcam(meetingId, userid, stream));
                    }
                } else if (MessagingConstants.USER_UNSHARE_WEBCAM_EVENT.equalsIgnoreCase(messageName)) {
                    String meetingId = payload.get("meeting_id").getAsString();
                    String userid = payload.get("userid").getAsString();
                    String stream = payload.get("stream").getAsString();
                    for (MessageListener listener : listeners) {
                        listener.handle(new UserUnsharedWebcam(meetingId, userid, stream));
                    }
                } else if (SendStunTurnInfoRequestMessage.SEND_STUN_TURN_INFO_REQUEST_MESSAGE.equalsIgnoreCase(messageName)) {
                    String meetingId = payload.get(Constants.MEETING_ID).getAsString();
                    String requesterId = payload.get(Constants.REQUESTER_ID).getAsString();
                    for (MessageListener listener : listeners) {
                        listener.handle(new StunTurnInfoRequested(meetingId, requesterId));
                    }
                }
            }
        }
    }
}
Also used : UserLeftVoice(org.bigbluebutton.api.messaging.messages.UserLeftVoice) MeetingStarted(org.bigbluebutton.api.messaging.messages.MeetingStarted) UserJoined(org.bigbluebutton.api.messaging.messages.UserJoined) CreateBreakoutRoom(org.bigbluebutton.api.messaging.messages.CreateBreakoutRoom) UserJoinedVoice(org.bigbluebutton.api.messaging.messages.UserJoinedVoice) JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) EndBreakoutRoom(org.bigbluebutton.api.messaging.messages.EndBreakoutRoom) UserUnsharedWebcam(org.bigbluebutton.api.messaging.messages.UserUnsharedWebcam) EndBreakoutRoomRequest(org.bigbluebutton.messages.EndBreakoutRoomRequest) CreateBreakoutRoomRequest(org.bigbluebutton.messages.CreateBreakoutRoomRequest) JsonParser(com.google.gson.JsonParser) UserListeningOnly(org.bigbluebutton.api.messaging.messages.UserListeningOnly) MeetingDestroyed(org.bigbluebutton.api.messaging.messages.MeetingDestroyed) UserLeft(org.bigbluebutton.api.messaging.messages.UserLeft) IMessage(org.bigbluebutton.api.messaging.messages.IMessage) UserStatusChanged(org.bigbluebutton.api.messaging.messages.UserStatusChanged) UserSharedWebcam(org.bigbluebutton.api.messaging.messages.UserSharedWebcam) MeetingEnded(org.bigbluebutton.api.messaging.messages.MeetingEnded) PubSubPongMessage(org.bigbluebutton.common.messages.PubSubPongMessage) KeepAliveReply(org.bigbluebutton.api.messaging.messages.KeepAliveReply) IBigBlueButtonMessage(org.bigbluebutton.common.messages.IBigBlueButtonMessage)

Example 3 with IBigBlueButtonMessage

use of org.bigbluebutton.common.messages.IBigBlueButtonMessage in project bigbluebutton by bigbluebutton.

the class MeetingMessageReceiver method handleMessage.

public void handleMessage(String pattern, String channel, String message) {
    if (channel.equalsIgnoreCase(MessagingConstants.TO_MEETING_CHANNEL)) {
        System.out.println("Meeting message: " + channel + " " + message);
        JsonParser parser = new JsonParser();
        JsonObject obj = (JsonObject) parser.parse(message);
        if (obj.has("header") && obj.has("payload")) {
            JsonObject header = (JsonObject) obj.get("header");
            if (header.has("name")) {
                String messageName = header.get("name").getAsString();
                if (CreateMeetingRequest.NAME.equals(messageName)) {
                    Gson gson = new Gson();
                    CreateMeetingRequest msg = gson.fromJson(message, CreateMeetingRequest.class);
                    bbbGW.handleBigBlueButtonMessage(msg);
                }
            }
        }
        IBigBlueButtonMessage msg = MessageFromJsonConverter.convert(message);
        if (msg != null) {
            if (msg instanceof EndMeetingMessage) {
                EndMeetingMessage emm = (EndMeetingMessage) msg;
                bbbGW.endMeeting(emm.meetingId);
            } else if (msg instanceof RegisterUserMessage) {
                RegisterUserMessage rum = (RegisterUserMessage) msg;
                bbbGW.registerUser(rum.meetingID, rum.internalUserId, rum.fullname, rum.role, rum.externUserID, rum.authToken, rum.avatarURL);
            } else if (msg instanceof DestroyMeetingMessage) {
                DestroyMeetingMessage dmm = (DestroyMeetingMessage) msg;
                bbbGW.destroyMeeting(dmm.meetingId);
            } else if (msg instanceof ValidateAuthTokenMessage) {
                ValidateAuthTokenMessage vam = (ValidateAuthTokenMessage) msg;
                String sessionId = "tobeimplemented";
                bbbGW.validateAuthToken(vam.meetingId, vam.userId, vam.token, vam.replyTo, sessionId);
            } else if (msg instanceof UserConnectedToGlobalAudio) {
                UserConnectedToGlobalAudio ustga = (UserConnectedToGlobalAudio) msg;
                Map<String, Object> logData = new HashMap<String, Object>();
                logData.put("voiceConf", ustga.voiceConf);
                logData.put("userId", ustga.userid);
                logData.put("username", ustga.name);
                logData.put("event", "user_connected_to_global_audio");
                logData.put("description", "User connected to global audio.");
                /*
					Gson gson = new Gson();
					String logStr =  gson.toJson(logData);
					System.out.println("User connected to global audio: data={}", logStr);
					 */
                bbbGW.userConnectedToGlobalAudio(ustga.voiceConf, ustga.userid, ustga.name);
            } else if (msg instanceof UserDisconnectedFromGlobalAudio) {
                UserDisconnectedFromGlobalAudio udfga = (UserDisconnectedFromGlobalAudio) msg;
                Map<String, Object> logData = new HashMap<String, Object>();
                logData.put("voiceConf", udfga.voiceConf);
                logData.put("userId", udfga.userid);
                logData.put("username", udfga.name);
                logData.put("event", "user_disconnected_from_global_audio");
                logData.put("description", "User disconnected from global audio.");
                /*
					Gson gson = new Gson();
					String logStr =  gson.toJson(logData);
					System.out.println("User disconnected from global audio: data={}", logStr);
					*/
                bbbGW.userDisconnectedFromGlobalAudio(udfga.voiceConf, udfga.userid, udfga.name);
            } else if (msg instanceof GetAllMeetingsRequest) {
                GetAllMeetingsRequest gamr = (GetAllMeetingsRequest) msg;
                bbbGW.getAllMeetings("no_need_of_a_meeting_id");
            } else {
                System.out.println("Unknown message: [" + message + "]");
            }
        } else {
            System.out.println("Failed to decode message: [" + message + "]");
        }
    } else if (channel.equalsIgnoreCase(MessagingConstants.TO_SYSTEM_CHANNEL)) {
        JsonParser parser = new JsonParser();
        JsonObject obj = (JsonObject) parser.parse(message);
        if (obj.has("header") && obj.has("payload")) {
            JsonObject header = (JsonObject) obj.get("header");
            if (header.has("name")) {
                String messageName = header.get("name").getAsString();
                if (PubSubPingMessage.PUBSUB_PING.equals(messageName)) {
                    Gson gson = new Gson();
                    PubSubPingMessage msg = gson.fromJson(message, PubSubPingMessage.class);
                    bbbGW.handleBigBlueButtonMessage(msg);
                } else {
                    IBigBlueButtonMessage msg = MessageFromJsonConverter.convert(message);
                    if (msg != null) {
                        if (msg instanceof KeepAliveMessage) {
                            KeepAliveMessage kam = (KeepAliveMessage) msg;
                            bbbGW.isAliveAudit(kam.keepAliveId);
                        }
                    } else {
                        System.out.println("Unknown message: [" + message + "]");
                    }
                }
            }
        }
    }
}
Also used : UserDisconnectedFromGlobalAudio(org.bigbluebutton.common.messages.UserDisconnectedFromGlobalAudio) KeepAliveMessage(org.bigbluebutton.common.messages.KeepAliveMessage) CreateMeetingRequest(org.bigbluebutton.messages.CreateMeetingRequest) HashMap(java.util.HashMap) JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) EndMeetingMessage(org.bigbluebutton.common.messages.EndMeetingMessage) UserConnectedToGlobalAudio(org.bigbluebutton.common.messages.UserConnectedToGlobalAudio) GetAllMeetingsRequest(org.bigbluebutton.common.messages.GetAllMeetingsRequest) PubSubPingMessage(org.bigbluebutton.common.messages.PubSubPingMessage) RegisterUserMessage(org.bigbluebutton.common.messages.RegisterUserMessage) JsonObject(com.google.gson.JsonObject) DestroyMeetingMessage(org.bigbluebutton.common.messages.DestroyMeetingMessage) IBigBlueButtonMessage(org.bigbluebutton.common.messages.IBigBlueButtonMessage) HashMap(java.util.HashMap) Map(java.util.Map) JsonParser(com.google.gson.JsonParser) ValidateAuthTokenMessage(org.bigbluebutton.common.messages.ValidateAuthTokenMessage)

Aggregations

IBigBlueButtonMessage (org.bigbluebutton.common.messages.IBigBlueButtonMessage)3 Gson (com.google.gson.Gson)2 JsonObject (com.google.gson.JsonObject)2 JsonParser (com.google.gson.JsonParser)2 PubSubPongMessage (org.bigbluebutton.common.messages.PubSubPongMessage)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 CreateBreakoutRoom (org.bigbluebutton.api.messaging.messages.CreateBreakoutRoom)1 EndBreakoutRoom (org.bigbluebutton.api.messaging.messages.EndBreakoutRoom)1 IMessage (org.bigbluebutton.api.messaging.messages.IMessage)1 KeepAliveReply (org.bigbluebutton.api.messaging.messages.KeepAliveReply)1 MeetingDestroyed (org.bigbluebutton.api.messaging.messages.MeetingDestroyed)1 MeetingEnded (org.bigbluebutton.api.messaging.messages.MeetingEnded)1 MeetingStarted (org.bigbluebutton.api.messaging.messages.MeetingStarted)1 UserJoined (org.bigbluebutton.api.messaging.messages.UserJoined)1 UserJoinedVoice (org.bigbluebutton.api.messaging.messages.UserJoinedVoice)1 UserLeft (org.bigbluebutton.api.messaging.messages.UserLeft)1 UserLeftVoice (org.bigbluebutton.api.messaging.messages.UserLeftVoice)1 UserListeningOnly (org.bigbluebutton.api.messaging.messages.UserListeningOnly)1 UserSharedWebcam (org.bigbluebutton.api.messaging.messages.UserSharedWebcam)1