Search in sources :

Example 51 with JsonParser

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

the class GetCurrentLayoutRequestMessage method fromJson.

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

Example 52 with JsonParser

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

the class GetPresentationInfoMessage method fromJson.

public static GetPresentationInfoMessage 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 (GET_PRESENTATION_INFO.equals(messageName)) {
                if (payload.has(Constants.MEETING_ID) && payload.has(Constants.REQUESTER_ID) && payload.has(Constants.REPLY_TO)) {
                    String meetingId = payload.get(Constants.MEETING_ID).getAsString();
                    String requesterId = payload.get(Constants.REQUESTER_ID).getAsString();
                    String replyTo = payload.get(Constants.REPLY_TO).getAsString();
                    return new GetPresentationInfoMessage(meetingId, requesterId, replyTo);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 53 with JsonParser

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

the class DeskShareRTMPBroadcastStartedEventMessage method fromJson.

public static DeskShareRTMPBroadcastStartedEventMessage 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_RTMP_BROADCAST_STARTED_MESSAGE.equals(messageName)) {
                if (payload.has(CONFERENCE_NAME) && payload.has(TIMESTAMP) && payload.has(VIDEO_HEIGHT) && payload.has(VIDEO_WIDTH) && payload.has(STREAMNAME)) {
                    String conferenceName = payload.get(CONFERENCE_NAME).getAsString();
                    String streamname = payload.get(STREAMNAME).getAsString();
                    String timestamp = payload.get(TIMESTAMP).getAsString();
                    int vh = payload.get(VIDEO_HEIGHT).getAsInt();
                    int vw = payload.get(VIDEO_WIDTH).getAsInt();
                    return new DeskShareRTMPBroadcastStartedEventMessage(conferenceName, streamname, vw, vh, timestamp);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 54 with JsonParser

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

the class DeskShareRTMPBroadcastStoppedEventMessage method fromJson.

public static DeskShareRTMPBroadcastStoppedEventMessage 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_RTMP_BROADCAST_STOPPED_MESSAGE.equals(messageName)) {
                if (payload.has(CONFERENCE_NAME) && payload.has(TIMESTAMP) && payload.has(VIDEO_HEIGHT) && payload.has(VIDEO_WIDTH) && payload.has(STREAMNAME)) {
                    String conferenceName = payload.get(CONFERENCE_NAME).getAsString();
                    String streamname = payload.get(STREAMNAME).getAsString();
                    String timestamp = payload.get(TIMESTAMP).getAsString();
                    int vh = payload.get(VIDEO_HEIGHT).getAsInt();
                    int vw = payload.get(VIDEO_WIDTH).getAsInt();
                    return new DeskShareRTMPBroadcastStoppedEventMessage(conferenceName, streamname, vw, vh, timestamp);
                }
            }
        }
    }
    return null;
}
Also used : JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Example 55 with JsonParser

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

the class DeskShareStopRTMPBroadcastEventMessage method fromJson.

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

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