Search in sources :

Example 61 with JsonParser

use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.

the class DeskShareHangUpEventMessage method fromJson.

public static DeskShareHangUpEventMessage 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 (DESKSHARE_HANG_UP_MESSAGE.equals(messageName)) {
                if (payload.has(CONFERENCE_NAME) && payload.has(FS_CONFERENCE_NAME) && payload.has(TIMESTAMP)) {
                    String conferenceName = payload.get(CONFERENCE_NAME).getAsString();
                    String fsConferenceName = payload.get(FS_CONFERENCE_NAME).getAsString();
                    String timestamp = payload.get(TIMESTAMP).getAsString();
                    return new DeskShareHangUpEventMessage(conferenceName, fsConferenceName, timestamp);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 62 with JsonParser

use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.

the class EjectUserFromVoiceConfRequestMessage method fromJson.

public static EjectUserFromVoiceConfRequestMessage 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 (EJECT_VOICE_USER_REQUEST.equals(messageName)) {
                if (payload.has(MEETING_ID) && payload.has(VOICE_CONF_ID) && payload.has(VOICE_USER_ID)) {
                    String id = payload.get(MEETING_ID).getAsString();
                    String voiceConfId = payload.get(VOICE_CONF_ID).getAsString();
                    String voiceUserId = payload.get(VOICE_USER_ID).getAsString();
                    return new EjectUserFromVoiceConfRequestMessage(id, voiceConfId, voiceUserId);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 63 with JsonParser

use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.

the class EditCaptionHistoryMessage method fromJson.

public static EditCaptionHistoryMessage 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 (EDIT_CAPTION_HISTORY.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID) && payload.has(Constants.USER_ID) && payload.has(Constants.START_INDEX) && payload.has(Constants.END_INDEX) && payload.has(Constants.LOCALE) && payload.has(Constants.LOCALE_CODE) && payload.has(Constants.TEXT)) {
                    String meetingID = payload.get(Constants.MEETING_ID).getAsString();
                    String userID = payload.get(Constants.USER_ID).getAsString();
                    Integer startIndex = payload.get(Constants.START_INDEX).getAsInt();
                    Integer endIndex = payload.get(Constants.END_INDEX).getAsInt();
                    String locale = payload.get(Constants.LOCALE).getAsString();
                    String localeCode = payload.get(Constants.LOCALE_CODE).getAsString();
                    String text = payload.get(Constants.TEXT).getAsString();
                    return new EditCaptionHistoryMessage(meetingID, userID, startIndex, endIndex, locale, localeCode, text);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 64 with JsonParser

use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.

the class EjectAllUsersFromVoiceConfRequestMessage method fromJson.

public static EjectAllUsersFromVoiceConfRequestMessage 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 (EJECT_ALL_VOICE_USERS_REQUEST.equals(messageName)) {
                if (payload.has(MEETING_ID) && payload.has(VOICE_CONF_ID)) {
                    String id = payload.get(MEETING_ID).getAsString();
                    String voiceConfId = payload.get(VOICE_CONF_ID).getAsString();
                    return new EjectAllUsersFromVoiceConfRequestMessage(id, voiceConfId);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 65 with JsonParser

use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.

the class UserClientMessageSender method handleUsersMessage.

public void handleUsersMessage(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");
        if (header.has("name")) {
            // Used for JSON unmarshalling
            Gson gson = new Gson();
            String messageName = header.get("name").getAsString();
            switch(messageName) {
                case ValidateAuthTokenReplyMessage.VALIDATE_AUTH_TOKEN_REPLY:
                    ValidateAuthTokenReplyMessage m = ValidateAuthTokenReplyMessage.fromJson(message);
                    if (m != null) {
                        processValidateAuthTokenReply(m);
                    }
                    break;
                case ValidateAuthTokenTimeoutMessage.VALIDATE_AUTH_TOKEN_TIMEOUT:
                    ValidateAuthTokenTimeoutMessage vattm = ValidateAuthTokenTimeoutMessage.fromJson(message);
                    if (vattm != null) {
                        processValidateAuthTokenTimeoutMessage(vattm);
                    }
                    break;
                case UserLeftMessage.USER_LEFT:
                    UserLeftMessage ulm = UserLeftMessage.fromJson(message);
                    if (ulm != null) {
                        processUserLeftMessage(ulm);
                    }
                    break;
                case UserJoinedMessage.USER_JOINED:
                    UserJoinedMessage ujm = UserJoinedMessage.fromJson(message);
                    if (ujm != null) {
                        processUserJoinedMessage(ujm);
                    }
                    break;
                case PresenterAssignedMessage.PRESENTER_ASSIGNED:
                    PresenterAssignedMessage pam = PresenterAssignedMessage.fromJson(message);
                    if (pam != null) {
                        processPresenterAssignedMessage(pam);
                    }
                    break;
                case UserStatusChangedMessage.USER_STATUS_CHANGED:
                    UserStatusChangedMessage usm = UserStatusChangedMessage.fromJson(message);
                    if (usm != null) {
                        processUserStatusChangedMessage(usm);
                    }
                    break;
                case UserEmojiStatusMessage.USER_EMOJI_STATUS:
                    UserEmojiStatusMessage urhm = UserEmojiStatusMessage.fromJson(message);
                    if (urhm != null) {
                        processUserEmojiStatusMessage(urhm);
                    }
                    break;
                case UserListeningOnlyMessage.USER_LISTENING_ONLY:
                    UserListeningOnlyMessage ulom = UserListeningOnlyMessage.fromJson(message);
                    if (ulom != null) {
                        processUserListeningOnlyMessage(ulom);
                    }
                    break;
                case UserSharedWebcamMessage.USER_SHARED_WEBCAM:
                    UserSharedWebcamMessage uswm = UserSharedWebcamMessage.fromJson(message);
                    if (uswm != null) {
                        processUserSharedWebcamMessage(uswm);
                    }
                    break;
                case UserUnsharedWebcamMessage.USER_UNSHARED_WEBCAM:
                    UserUnsharedWebcamMessage uuwm = UserUnsharedWebcamMessage.fromJson(message);
                    if (uuwm != null) {
                        processUserUnsharedWebcamMessage(uuwm);
                    }
                    break;
                case UserJoinedVoiceMessage.USER_JOINED_VOICE:
                    UserJoinedVoiceMessage ujvm = UserJoinedVoiceMessage.fromJson(message);
                    if (ujvm != null) {
                        processUserJoinedVoiceMessage(ujvm);
                    }
                    break;
                case UserLeftVoiceMessage.USER_LEFT_VOICE:
                    UserLeftVoiceMessage ulvm = UserLeftVoiceMessage.fromJson(message);
                    if (ulvm != null) {
                        processUserLeftVoiceMessage(ulvm);
                    }
                    break;
                case UserVoiceMutedMessage.USER_VOICE_MUTED:
                    UserVoiceMutedMessage uvmm = UserVoiceMutedMessage.fromJson(message);
                    if (uvmm != null) {
                        processUserVoiceMutedMessage(uvmm);
                    }
                    break;
                case UserVoiceTalkingMessage.USER_VOICE_TALKING:
                    UserVoiceTalkingMessage uvtm = UserVoiceTalkingMessage.fromJson(message);
                    if (uvtm != null) {
                        processUserVoiceTalkingMessage(uvtm);
                    }
                    break;
                case RecordingStatusChangedMessage.RECORDING_STATUS_CHANGED:
                    RecordingStatusChangedMessage rscm = RecordingStatusChangedMessage.fromJson(message);
                    if (rscm != null) {
                        processRecordingStatusChangedMessage(rscm);
                    }
                    break;
                case GetRecordingStatusReplyMessage.Get_RECORDING_STATUS_REPLY:
                    GetRecordingStatusReplyMessage grsrm = GetRecordingStatusReplyMessage.fromJson(message);
                    if (grsrm != null) {
                        processGetRecordingStatusReplyMessage(grsrm);
                    }
                    break;
                case GetUsersReplyMessage.GET_USERS_REPLY:
                    GetUsersReplyMessage gurm = GetUsersReplyMessage.fromJson(message);
                    if (gurm != null) {
                        processGetUsersReplyMessage(gurm);
                    }
                    break;
                case GetCurrentLayoutReplyMessage.GET_CURRENT_LAYOUT_REPLY:
                    processGetCurrentLayoutReplyMessage(message);
                    break;
                case BroadcastLayoutMessage.BROADCAST_LAYOUT:
                    processBroadcastLayoutMessage(message);
                    break;
                case LockLayoutMessage.LOCK_LAYOUT:
                    processLockLayoutMessage(message);
                    break;
                case UserEjectedFromMeetingMessage.USER_EJECTED_FROM_MEETING:
                    processUserEjectedFromMeetingMessage(message);
                    break;
                case BreakoutRoomsList.NAME:
                    BreakoutRoomsList brl = gson.fromJson(message, BreakoutRoomsList.class);
                    if (brl != null) {
                        processBreakoutRoomsList(brl);
                    }
                    break;
                case BreakoutRoomJoinURL.NAME:
                    BreakoutRoomJoinURL brjum = gson.fromJson(message, BreakoutRoomJoinURL.class);
                    if (brjum != null) {
                        processBreakoutRoomJoinURL(brjum);
                    }
                    break;
                case TimeRemainingUpdate.NAME:
                    TimeRemainingUpdate trum = gson.fromJson(message, TimeRemainingUpdate.class);
                    if (trum != null) {
                        processTimeRemainingUpdate(trum);
                    }
                    break;
                case BreakoutRoomsTimeRemainingUpdate.NAME:
                    BreakoutRoomsTimeRemainingUpdate brtru = gson.fromJson(message, BreakoutRoomsTimeRemainingUpdate.class);
                    if (brtru != null) {
                        processBreakoutRoomsTimeRemainingUpdate(brtru);
                    }
                    break;
                case UpdateBreakoutUsers.NAME:
                    UpdateBreakoutUsers ubum = gson.fromJson(message, UpdateBreakoutUsers.class);
                    if (ubum != null) {
                        processUpdateBreakoutUsers(ubum);
                    }
                    break;
                case BreakoutRoomStarted.NAME:
                    BreakoutRoomStarted brsm = gson.fromJson(message, BreakoutRoomStarted.class);
                    if (brsm != null) {
                        processBreakoutRoomStarted(brsm);
                    }
                    break;
                case BreakoutRoomClosed.NAME:
                    BreakoutRoomClosed brcm = gson.fromJson(message, BreakoutRoomClosed.class);
                    if (brcm != null) {
                        processBreakoutRoomClosed(brcm);
                    }
                    break;
            }
        }
    }
}
Also used : UserLeftMessage(org.bigbluebutton.common.messages.UserLeftMessage) UserSharedWebcamMessage(org.bigbluebutton.common.messages.UserSharedWebcamMessage) UserStatusChangedMessage(org.bigbluebutton.common.messages.UserStatusChangedMessage) UserVoiceMutedMessage(org.bigbluebutton.common.messages.UserVoiceMutedMessage) UserUnsharedWebcamMessage(org.bigbluebutton.common.messages.UserUnsharedWebcamMessage) TimeRemainingUpdate(org.bigbluebutton.messages.TimeRemainingUpdate) BreakoutRoomsTimeRemainingUpdate(org.bigbluebutton.messages.BreakoutRoomsTimeRemainingUpdate) UserVoiceTalkingMessage(org.bigbluebutton.common.messages.UserVoiceTalkingMessage) GetUsersReplyMessage(org.bigbluebutton.common.messages.GetUsersReplyMessage) JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) BreakoutRoomClosed(org.bigbluebutton.messages.BreakoutRoomClosed) UserJoinedMessage(org.bigbluebutton.common.messages.UserJoinedMessage) BreakoutRoomsTimeRemainingUpdate(org.bigbluebutton.messages.BreakoutRoomsTimeRemainingUpdate) PresenterAssignedMessage(org.bigbluebutton.common.messages.PresenterAssignedMessage) UserLeftVoiceMessage(org.bigbluebutton.common.messages.UserLeftVoiceMessage) UserEmojiStatusMessage(org.bigbluebutton.common.messages.UserEmojiStatusMessage) JsonParser(com.google.gson.JsonParser) UpdateBreakoutUsers(org.bigbluebutton.messages.UpdateBreakoutUsers) BreakoutRoomStarted(org.bigbluebutton.messages.BreakoutRoomStarted) ValidateAuthTokenTimeoutMessage(org.bigbluebutton.common.messages.ValidateAuthTokenTimeoutMessage) BreakoutRoomsList(org.bigbluebutton.messages.BreakoutRoomsList) GetRecordingStatusReplyMessage(org.bigbluebutton.common.messages.GetRecordingStatusReplyMessage) ValidateAuthTokenReplyMessage(org.bigbluebutton.common.messages.ValidateAuthTokenReplyMessage) UserJoinedVoiceMessage(org.bigbluebutton.common.messages.UserJoinedVoiceMessage) UserListeningOnlyMessage(org.bigbluebutton.common.messages.UserListeningOnlyMessage) RecordingStatusChangedMessage(org.bigbluebutton.common.messages.RecordingStatusChangedMessage) BreakoutRoomJoinURL(org.bigbluebutton.messages.BreakoutRoomJoinURL)

Aggregations

JsonParser (com.google.gson.JsonParser)356 JsonObject (com.google.gson.JsonObject)285 JsonElement (com.google.gson.JsonElement)105 JsonArray (com.google.gson.JsonArray)57 IOException (java.io.IOException)43 Gson (com.google.gson.Gson)40 InputStreamReader (java.io.InputStreamReader)32 ArrayList (java.util.ArrayList)20 HashMap (java.util.HashMap)20 Map (java.util.Map)18 Type (java.lang.reflect.Type)15 JsonReader (com.google.gson.stream.JsonReader)12 Test (org.junit.Test)12 URL (java.net.URL)11 AssetManager (android.content.res.AssetManager)10 InputStream (java.io.InputStream)10 GsonBuilder (com.google.gson.GsonBuilder)9 UserType (com.glitchcog.fontificator.bot.UserType)8 EmojiType (com.glitchcog.fontificator.emoji.EmojiType)8 JsonParseException (com.google.gson.JsonParseException)8