use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.
the class UndoWhiteboardRequest method fromJson.
public static UndoWhiteboardRequest 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 (UNDO_WHITEBOARD_REQUEST.equals(messageName)) {
if (payload.has(Constants.MEETING_ID) && payload.has(Constants.WHITEBOARD_ID) && payload.has(Constants.REQUESTER_ID)) {
String meetingId = payload.get(Constants.MEETING_ID).getAsString();
String whiteboardId = payload.get(Constants.WHITEBOARD_ID).getAsString();
String requesterId = payload.get(Constants.REQUESTER_ID).getAsString();
return new UndoWhiteboardRequest(meetingId, requesterId, whiteboardId);
}
}
}
}
return null;
}
use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.
the class PresentationPageGeneratedReplyMessage method fromJson.
public static PresentationPageGeneratedReplyMessage 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 (PRESENTATION_PAGE_GENERATED.equals(messageName)) {
if (payload.has(Constants.MEETING_ID) && payload.has(Constants.CODE) && payload.has(Constants.MESSAGE_KEY) && payload.has(Constants.PRESENTATION_NAME) && payload.has(Constants.NUM_PAGES) && payload.has(Constants.PAGES_COMPLETED) && payload.has(Constants.PRESENTATION_ID)) {
String meetingId = payload.get(Constants.MEETING_ID).getAsString();
String presentationId = payload.get(Constants.PRESENTATION_ID).getAsString();
String presentationName = payload.get(Constants.PRESENTATION_NAME).getAsString();
String code = payload.get(Constants.CODE).getAsString();
String messageKey = payload.get(Constants.MESSAGE_KEY).getAsString();
int numPages = payload.get(Constants.NUM_PAGES).getAsInt();
int pagesCompleted = payload.get(Constants.PAGES_COMPLETED).getAsInt();
return new PresentationPageGeneratedReplyMessage(meetingId, presentationId, numPages, code, messageKey, presentationName, pagesCompleted);
}
}
}
}
return null;
}
use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.
the class PresentationSharedMessage method fromJson.
public static PresentationSharedMessage 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 (PRESENTATION_SHARED_MESSAGE.equals(messageName)) {
if (payload.has(Constants.MEETING_ID) && payload.has(Constants.PRESENTATION)) {
String meetingId = payload.get(Constants.MEETING_ID).getAsString();
JsonObject presentationObject = (JsonObject) payload.get(Constants.PRESENTATION).getAsJsonObject();
Util util = new Util();
Map<String, Object> presentation = util.extractPresentation(presentationObject);
return new PresentationSharedMessage(meetingId, presentation);
}
}
}
}
return null;
}
use of com.google.gson.JsonParser in project commons by twitter.
the class JsonCodecTest method testExpectedFormat.
@Test
public void testExpectedFormat() throws IOException {
Codec<TestClass> codec = JsonCodec.create(TestClass.class);
TestClass item = createTestClassInstance();
JsonElement expectedElement = new JsonParser().parse("{\"data1\":\"foo\",\"data2\":\"bar\",\"data3\":42,\"data4\":[\"abc\",\"def\"]}");
JsonElement actualElement = new JsonParser().parse(new String(serialize(codec, item), "utf-8"));
assertEquals(expectedElement.toString(), actualElement.toString());
}
use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.
the class WhiteboardMessageReceiver method handleMessage.
@Override
public void handleMessage(String pattern, String channel, String message) {
if (channel.equalsIgnoreCase(MessagingConstants.TO_WHITEBOARD_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 (UndoWhiteboardRequest.UNDO_WHITEBOARD_REQUEST.equals(messageName)) {
UndoWhiteboardRequest msg = UndoWhiteboardRequest.fromJson(message);
bbbInGW.undoWhiteboard(msg.meetingId, msg.requesterId, msg.whiteboardId);
} else if (ClearWhiteboardRequestMessage.CLEAR_WHITEBOARD_REQUEST.equals(messageName)) {
ClearWhiteboardRequestMessage msg = ClearWhiteboardRequestMessage.fromJson(message);
bbbInGW.clearWhiteboard(msg.meetingId, msg.requesterId, msg.whiteboardId);
} else if (RequestWhiteboardAnnotationHistoryRequestMessage.REQUEST_WHITEBOARD_ANNOTATION_HISTORY_REQUEST.equals(messageName)) {
RequestWhiteboardAnnotationHistoryRequestMessage msg = RequestWhiteboardAnnotationHistoryRequestMessage.fromJson(message);
bbbInGW.requestWhiteboardAnnotationHistory(msg.meetingId, msg.requesterId, msg.whiteboardId, msg.replyTo);
} else if (IsWhiteboardEnabledRequestMessage.IS_WHITEBOARD_ENABLED_REQUEST.equals(messageName)) {
IsWhiteboardEnabledRequestMessage msg = IsWhiteboardEnabledRequestMessage.fromJson(message);
bbbInGW.isWhiteboardEnabled(msg.meetingId, msg.requesterId, msg.replyTo);
} else if (EnableWhiteboardRequestMessage.ENABLE_WHITEBOARD_REQUEST.equals(messageName)) {
EnableWhiteboardRequestMessage msg = EnableWhiteboardRequestMessage.fromJson(message);
bbbInGW.enableWhiteboard(msg.meetingId, msg.requesterId, msg.enable);
} else if (SendWhiteboardAnnotationRequestMessage.SEND_WHITEBOARD_ANNOTATION_REQUEST.equals(messageName)) {
SendWhiteboardAnnotationRequestMessage msg = SendWhiteboardAnnotationRequestMessage.fromJson(message);
bbbInGW.sendWhiteboardAnnotation(msg.meetingId, msg.requesterId, msg.annotation);
}
}
}
}
}
Aggregations