use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.
the class FromJsonDecoder method decodeMessage.
public IBigBlueButtonMessage decodeMessage(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")) {
String messageName = header.get("name").getAsString();
if (PubSubPingMessage.PUBSUB_PING.equals(messageName)) {
Gson gson = new Gson();
PubSubPingMessage msg = gson.fromJson(message, PubSubPingMessage.class);
return msg;
} else if (PubSubPongMessage.PUBSUB_PONG.equals(messageName)) {
Gson gson = new Gson();
PubSubPongMessage msg = gson.fromJson(message, PubSubPongMessage.class);
return msg;
} else if (StartCustomPollRequestMessage.START_CUSTOM_POLL_REQUEST.equals(messageName)) {
Gson gson = new Gson();
StartCustomPollRequestMessage msg = gson.fromJson(message, StartCustomPollRequestMessage.class);
return msg;
} else {
// System.out.println("Unknown message name=[" + messageName + "]");
return null;
}
}
}
System.out.println("Invalid message format");
return null;
}
use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.
the class AllowUserToShareDesktopReply method fromJson.
public static AllowUserToShareDesktopReply 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 (NAME.equals(messageName)) {
if (payload.has(TIMESTAMP) && payload.has(MEETING_ID) && payload.has(USER_ID) && payload.has(ALLOWED)) {
Long timestamp = payload.get(TIMESTAMP).getAsLong();
String meetingId = payload.get(MEETING_ID).getAsString();
String userId = payload.get(USER_ID).getAsString();
Boolean allowed = payload.get(ALLOWED).getAsBoolean();
return new AllowUserToShareDesktopReply(meetingId, userId, allowed, timestamp);
}
}
}
}
return null;
}
use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.
the class AssignPresenterRequestMessage method fromJson.
public static AssignPresenterRequestMessage 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 (ASSIGN_PRESENTER_REQUEST.equals(messageName)) {
if (payload.has(Constants.MEETING_ID) && payload.has(Constants.NEW_PRESENTER_ID) && payload.has(Constants.NEW_PRESENTER_NAME) && payload.has(Constants.ASSIGNED_BY)) {
String meetingId = payload.get(Constants.MEETING_ID).getAsString();
String newPresenterId = payload.get(Constants.NEW_PRESENTER_ID).getAsString();
String newPresenterName = payload.get(Constants.NEW_PRESENTER_NAME).getAsString();
String assignedBy = payload.get(Constants.ASSIGNED_BY).getAsString();
return new AssignPresenterRequestMessage(meetingId, newPresenterId, newPresenterName, assignedBy);
}
}
}
}
return null;
}
use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.
the class GetChatHistoryReplyMessage method fromJson.
public static GetChatHistoryReplyMessage 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_CHAT_HISTORY_REPLY.equals(messageName)) {
if (payload.has(Constants.MEETING_ID) && payload.has(Constants.CHAT_HISTORY) && payload.has(Constants.REQUESTER_ID)) {
String meetingId = payload.get(Constants.MEETING_ID).getAsString();
String requesterId = payload.get(Constants.REQUESTER_ID).getAsString();
JsonArray history = (JsonArray) payload.get(Constants.CHAT_HISTORY);
Util util = new Util();
ArrayList<Map<String, Object>> chatHistory = util.extractChatHistory(history);
return new GetChatHistoryReplyMessage(meetingId, requesterId, chatHistory);
}
}
}
}
return null;
}
use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.
the class GetChatHistoryRequestMessage method fromJson.
public static GetChatHistoryRequestMessage 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_CHAT_HISTORY_REQUEST.equals(messageName)) {
if (payload.has(Constants.MEETING_ID) && payload.has(Constants.REPLY_TO) && payload.has(Constants.REQUESTER_ID)) {
String meetingId = payload.get(Constants.MEETING_ID).getAsString();
String replyTo = payload.get(Constants.REPLY_TO).getAsString();
String requesterId = payload.get(Constants.REQUESTER_ID).getAsString();
return new GetChatHistoryRequestMessage(meetingId, requesterId, replyTo);
}
}
}
}
return null;
}
Aggregations