Search in sources :

Example 1 with KeepAliveMessage

use of org.bigbluebutton.common.messages.KeepAliveMessage 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

Gson (com.google.gson.Gson)1 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 DestroyMeetingMessage (org.bigbluebutton.common.messages.DestroyMeetingMessage)1 EndMeetingMessage (org.bigbluebutton.common.messages.EndMeetingMessage)1 GetAllMeetingsRequest (org.bigbluebutton.common.messages.GetAllMeetingsRequest)1 IBigBlueButtonMessage (org.bigbluebutton.common.messages.IBigBlueButtonMessage)1 KeepAliveMessage (org.bigbluebutton.common.messages.KeepAliveMessage)1 PubSubPingMessage (org.bigbluebutton.common.messages.PubSubPingMessage)1 RegisterUserMessage (org.bigbluebutton.common.messages.RegisterUserMessage)1 UserConnectedToGlobalAudio (org.bigbluebutton.common.messages.UserConnectedToGlobalAudio)1 UserDisconnectedFromGlobalAudio (org.bigbluebutton.common.messages.UserDisconnectedFromGlobalAudio)1 ValidateAuthTokenMessage (org.bigbluebutton.common.messages.ValidateAuthTokenMessage)1 CreateMeetingRequest (org.bigbluebutton.messages.CreateMeetingRequest)1