Search in sources :

Example 56 with JsonObject

use of com.google.gson.JsonObject 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 57 with JsonObject

use of com.google.gson.JsonObject 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 58 with JsonObject

use of com.google.gson.JsonObject 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 59 with JsonObject

use of com.google.gson.JsonObject 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 60 with JsonObject

use of com.google.gson.JsonObject 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

JsonObject (com.google.gson.JsonObject)1417 JsonElement (com.google.gson.JsonElement)389 JsonArray (com.google.gson.JsonArray)293 JsonParser (com.google.gson.JsonParser)285 JsonPrimitive (com.google.gson.JsonPrimitive)137 Gson (com.google.gson.Gson)91 Test (org.junit.Test)81 HashMap (java.util.HashMap)79 Map (java.util.Map)78 ArrayList (java.util.ArrayList)77 IOException (java.io.IOException)66 Test (org.testng.annotations.Test)61 InputStreamReader (java.io.InputStreamReader)38 JsonParseException (com.google.gson.JsonParseException)27 File (java.io.File)25 List (java.util.List)21 HttpResponse (org.apache.http.HttpResponse)21 JsonReader (com.google.gson.stream.JsonReader)19 InvalidArgumentException (com.pratilipi.common.exception.InvalidArgumentException)19 InputStream (java.io.InputStream)19