use of com.google.gson.JsonObject in project disunity by ata4.
the class JsonTablePrinter method print.
@Override
public void print(Collection<TableModel> models) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
JsonObject jsonRoot = new JsonObject();
if (file != null) {
jsonRoot.add("file", new JsonPrimitive(file.toString()));
}
models.forEach(model -> {
jsonRoot.add(model.name().toLowerCase(), tableToJson(model.table(), gson));
});
gson.toJson(jsonRoot, out);
}
use of com.google.gson.JsonObject in project disunity by ata4.
the class AssetTypes method printJson.
private void printJson(Path file, TypeTree<? extends Type> typeTree) {
Gson gson = new GsonBuilder().setPrettyPrinting().create();
JsonObject jsonTypeTree = new JsonObject();
jsonTypeTree.addProperty("file", file.toString());
if (typeTree.embedded()) {
JsonArray jsonTypes = new JsonArray();
typeTree.typeMap().forEach((path, typeRoot) -> {
JsonObject jsonTypeNode = new JsonObject();
jsonTypeNode.addProperty("pathID", path);
jsonTypeNode.addProperty("classID", typeRoot.classID());
if (typeRoot.scriptID() != null) {
jsonTypeNode.addProperty("scriptID", typeRoot.scriptID().toString());
}
if (typeRoot.oldTypeHash() != null) {
jsonTypeNode.addProperty("oldTypeHash", typeRoot.oldTypeHash().toString());
}
jsonTypeNode.add("nodes", typeNodeToJson(typeRoot.nodes(), gson));
jsonTypes.add(jsonTypeNode);
});
jsonTypeTree.add("types", jsonTypes);
}
gson.toJson(jsonTypeTree, output());
}
use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.
the class UserClientMessageSender method handleUsersMessage.
public void handleUsersMessage(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")) {
// Used for JSON unmarshalling
Gson gson = new Gson();
String messageName = header.get("name").getAsString();
switch(messageName) {
case ValidateAuthTokenReplyMessage.VALIDATE_AUTH_TOKEN_REPLY:
ValidateAuthTokenReplyMessage m = ValidateAuthTokenReplyMessage.fromJson(message);
if (m != null) {
processValidateAuthTokenReply(m);
}
break;
case ValidateAuthTokenTimeoutMessage.VALIDATE_AUTH_TOKEN_TIMEOUT:
ValidateAuthTokenTimeoutMessage vattm = ValidateAuthTokenTimeoutMessage.fromJson(message);
if (vattm != null) {
processValidateAuthTokenTimeoutMessage(vattm);
}
break;
case UserLeftMessage.USER_LEFT:
UserLeftMessage ulm = UserLeftMessage.fromJson(message);
if (ulm != null) {
processUserLeftMessage(ulm);
}
break;
case UserJoinedMessage.USER_JOINED:
UserJoinedMessage ujm = UserJoinedMessage.fromJson(message);
if (ujm != null) {
processUserJoinedMessage(ujm);
}
break;
case PresenterAssignedMessage.PRESENTER_ASSIGNED:
PresenterAssignedMessage pam = PresenterAssignedMessage.fromJson(message);
if (pam != null) {
processPresenterAssignedMessage(pam);
}
break;
case UserStatusChangedMessage.USER_STATUS_CHANGED:
UserStatusChangedMessage usm = UserStatusChangedMessage.fromJson(message);
if (usm != null) {
processUserStatusChangedMessage(usm);
}
break;
case UserEmojiStatusMessage.USER_EMOJI_STATUS:
UserEmojiStatusMessage urhm = UserEmojiStatusMessage.fromJson(message);
if (urhm != null) {
processUserEmojiStatusMessage(urhm);
}
break;
case UserListeningOnlyMessage.USER_LISTENING_ONLY:
UserListeningOnlyMessage ulom = UserListeningOnlyMessage.fromJson(message);
if (ulom != null) {
processUserListeningOnlyMessage(ulom);
}
break;
case UserSharedWebcamMessage.USER_SHARED_WEBCAM:
UserSharedWebcamMessage uswm = UserSharedWebcamMessage.fromJson(message);
if (uswm != null) {
processUserSharedWebcamMessage(uswm);
}
break;
case UserUnsharedWebcamMessage.USER_UNSHARED_WEBCAM:
UserUnsharedWebcamMessage uuwm = UserUnsharedWebcamMessage.fromJson(message);
if (uuwm != null) {
processUserUnsharedWebcamMessage(uuwm);
}
break;
case UserJoinedVoiceMessage.USER_JOINED_VOICE:
UserJoinedVoiceMessage ujvm = UserJoinedVoiceMessage.fromJson(message);
if (ujvm != null) {
processUserJoinedVoiceMessage(ujvm);
}
break;
case UserLeftVoiceMessage.USER_LEFT_VOICE:
UserLeftVoiceMessage ulvm = UserLeftVoiceMessage.fromJson(message);
if (ulvm != null) {
processUserLeftVoiceMessage(ulvm);
}
break;
case UserVoiceMutedMessage.USER_VOICE_MUTED:
UserVoiceMutedMessage uvmm = UserVoiceMutedMessage.fromJson(message);
if (uvmm != null) {
processUserVoiceMutedMessage(uvmm);
}
break;
case UserVoiceTalkingMessage.USER_VOICE_TALKING:
UserVoiceTalkingMessage uvtm = UserVoiceTalkingMessage.fromJson(message);
if (uvtm != null) {
processUserVoiceTalkingMessage(uvtm);
}
break;
case RecordingStatusChangedMessage.RECORDING_STATUS_CHANGED:
RecordingStatusChangedMessage rscm = RecordingStatusChangedMessage.fromJson(message);
if (rscm != null) {
processRecordingStatusChangedMessage(rscm);
}
break;
case GetRecordingStatusReplyMessage.Get_RECORDING_STATUS_REPLY:
GetRecordingStatusReplyMessage grsrm = GetRecordingStatusReplyMessage.fromJson(message);
if (grsrm != null) {
processGetRecordingStatusReplyMessage(grsrm);
}
break;
case GetUsersReplyMessage.GET_USERS_REPLY:
GetUsersReplyMessage gurm = GetUsersReplyMessage.fromJson(message);
if (gurm != null) {
processGetUsersReplyMessage(gurm);
}
break;
case GetCurrentLayoutReplyMessage.GET_CURRENT_LAYOUT_REPLY:
processGetCurrentLayoutReplyMessage(message);
break;
case BroadcastLayoutMessage.BROADCAST_LAYOUT:
processBroadcastLayoutMessage(message);
break;
case LockLayoutMessage.LOCK_LAYOUT:
processLockLayoutMessage(message);
break;
case UserEjectedFromMeetingMessage.USER_EJECTED_FROM_MEETING:
processUserEjectedFromMeetingMessage(message);
break;
case BreakoutRoomsList.NAME:
BreakoutRoomsList brl = gson.fromJson(message, BreakoutRoomsList.class);
if (brl != null) {
processBreakoutRoomsList(brl);
}
break;
case BreakoutRoomJoinURL.NAME:
BreakoutRoomJoinURL brjum = gson.fromJson(message, BreakoutRoomJoinURL.class);
if (brjum != null) {
processBreakoutRoomJoinURL(brjum);
}
break;
case TimeRemainingUpdate.NAME:
TimeRemainingUpdate trum = gson.fromJson(message, TimeRemainingUpdate.class);
if (trum != null) {
processTimeRemainingUpdate(trum);
}
break;
case BreakoutRoomsTimeRemainingUpdate.NAME:
BreakoutRoomsTimeRemainingUpdate brtru = gson.fromJson(message, BreakoutRoomsTimeRemainingUpdate.class);
if (brtru != null) {
processBreakoutRoomsTimeRemainingUpdate(brtru);
}
break;
case UpdateBreakoutUsers.NAME:
UpdateBreakoutUsers ubum = gson.fromJson(message, UpdateBreakoutUsers.class);
if (ubum != null) {
processUpdateBreakoutUsers(ubum);
}
break;
case BreakoutRoomStarted.NAME:
BreakoutRoomStarted brsm = gson.fromJson(message, BreakoutRoomStarted.class);
if (brsm != null) {
processBreakoutRoomStarted(brsm);
}
break;
case BreakoutRoomClosed.NAME:
BreakoutRoomClosed brcm = gson.fromJson(message, BreakoutRoomClosed.class);
if (brcm != null) {
processBreakoutRoomClosed(brcm);
}
break;
}
}
}
}
use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.
the class MeetingClientMessageSender method handleMeetingMessage.
public void handleMeetingMessage(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();
switch(messageName) {
case DisconnectUserMessage.DISCONNECT_USER:
DisconnectUserMessage m = DisconnectUserMessage.fromJson(message);
if (m != null) {
processDisconnectUserMessage(m);
}
break;
case DisconnectAllUsersMessage.DISCONNECT_All_USERS:
DisconnectAllUsersMessage daum = DisconnectAllUsersMessage.fromJson(message);
if (daum != null) {
processDisconnectAllUsersMessage(daum);
}
break;
case MeetingEndedMessage.MEETING_ENDED:
MeetingEndedMessage mem = MeetingEndedMessage.fromJson(message);
if (mem != null) {
processMeetingEndedMessage(mem);
}
break;
case MeetingEndingMessage.MEETING_ENDING:
MeetingEndingMessage me = MeetingEndingMessage.fromJson(message);
if (me != null) {
processMeetingEndingMessage(me);
}
break;
case MeetingHasEndedMessage.MEETING_HAS_ENDED:
MeetingHasEndedMessage mhem = MeetingHasEndedMessage.fromJson(message);
if (mhem != null) {
processMeetingHasEndedMessage(mhem);
}
break;
case MeetingStateMessage.MEETING_STATE:
MeetingStateMessage msm = MeetingStateMessage.fromJson(message);
if (msm != null) {
processMeetingStateMessage(msm);
}
break;
case NewPermissionsSettingMessage.NEW_PERMISSIONS_SETTING:
NewPermissionsSettingMessage npsm = NewPermissionsSettingMessage.fromJson(message);
if (npsm != null) {
processNewPermissionsSettingMessage(npsm);
}
break;
case MeetingMutedMessage.MEETING_MUTED:
MeetingMutedMessage mmm = MeetingMutedMessage.fromJson(message);
if (mmm != null) {
processMeetingMutedMessage(mmm);
}
break;
case UserLockedMessage.USER_LOCKED:
UserLockedMessage ulm = UserLockedMessage.fromJson(message);
if (ulm != null) {
processUserLockedMessage(ulm);
}
break;
}
}
}
}
use of com.google.gson.JsonObject in project bigbluebutton by bigbluebutton.
the class PollingClientMessageSender method handlePollMessage.
public void handlePollMessage(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();
switch(messageName) {
case PollStartedMessage.POLL_STARTED:
processPollStartedMessage(message);
break;
case PollStoppedMessage.POLL_STOPPED:
processPollStoppedMessage(message);
break;
case PollShowResultMessage.POLL_SHOW_RESULT:
processPollShowResultMessage(message);
break;
case UserVotedPollMessage.USER_VOTED_POLL:
processUserVotedPollMessage(message);
break;
}
}
}
}
Aggregations