use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.
the class MeetingCreatedMessage method fromJson.
public static MeetingCreatedMessage 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 (MEETING_CREATED.equals(messageName)) {
if (payload.has(Constants.MEETING_ID) && payload.has(Constants.RECORDED)) {
String meetingId = payload.get(Constants.MEETING_ID).getAsString();
Boolean record = payload.get(Constants.RECORDED).getAsBoolean();
return new MeetingCreatedMessage(meetingId, record);
}
}
}
}
return null;
}
use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.
the class MeetingEndedMessage method fromJson.
public static MeetingEndedMessage 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 (MEETING_ENDED.equals(messageName)) {
if (payload.has(Constants.MEETING_ID)) {
String meetingId = payload.get(Constants.MEETING_ID).getAsString();
return new MeetingEndedMessage(meetingId);
}
}
}
}
return null;
}
use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.
the class MeetingEndingMessage method fromJson.
public static MeetingEndingMessage 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 (MEETING_ENDING.equals(messageName)) {
if (payload.has(Constants.MEETING_ID)) {
String meetingId = payload.get(Constants.MEETING_ID).getAsString();
return new MeetingEndingMessage(meetingId);
}
}
}
}
return null;
}
use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.
the class MeetingMutedMessage method fromJson.
public static MeetingMutedMessage 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 (MEETING_MUTED.equals(messageName)) {
if (payload.has(Constants.MEETING_ID) && payload.has(Constants.MEETING_MUTED)) {
String meetingID = payload.get(Constants.MEETING_ID).getAsString();
Boolean muted = payload.get(Constants.MEETING_MUTED).getAsBoolean();
return new MeetingMutedMessage(meetingID, muted);
}
}
}
}
return null;
}
use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.
the class MessageFromJsonConverter method convert.
public static IBigBlueButtonMessage convert(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();
switch(messageName) {
case CreateMeetingMessage.CREATE_MEETING_REQUEST_EVENT:
return processCreateMeeting(payload);
case DestroyMeetingMessage.DESTROY_MEETING_REQUEST_EVENT:
return processDestroyMeeting(payload);
case EndMeetingMessage.END_MEETING_REQUEST_EVENT:
return processEndMeetingMessage(payload);
case KeepAliveMessage.KEEP_ALIVE_REQUEST:
return processKeepAlive(payload);
case RegisterUserMessage.REGISTER_USER:
return RegisterUserMessage.fromJson(message);
case ValidateAuthTokenMessage.VALIDATE_AUTH_TOKEN:
return processValidateAuthTokenMessage(header, payload);
// return ValidateAuthTokenMessage.fromJson(message);
case UserConnectedToGlobalAudio.USER_CONNECTED_TO_GLOBAL_AUDIO:
return UserConnectedToGlobalAudio.fromJson(message);
case UserDisconnectedFromGlobalAudio.USER_DISCONNECTED_FROM_GLOBAL_AUDIO:
return UserDisconnectedFromGlobalAudio.fromJson(message);
case GetAllMeetingsRequest.GET_ALL_MEETINGS_REQUEST_EVENT:
return new GetAllMeetingsRequest("the_string_is_not_used_anywhere");
}
}
}
return null;
}
Aggregations