Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.bigbluebutton.common.messages;
 
 
 public class MessageFromJsonConverter {
 
 	public static IPublishedMessage convert(String message) {
 		JsonParser parser = new JsonParser();
		JsonObject obj = (JsonObjectparser.parse(message);
		if (obj.has("header") && obj.has("payload")) {
			JsonObject header = (JsonObjectobj.get("header");
			JsonObject payload = (JsonObjectobj.get("payload");
			if (header.has("name")) {
				String messageName = header.get("name").getAsString();
				switch (messageName) {
					  return processCreateMeeting(payload);
					  return processDestroyMeeting(payload);
					  return processEndMeetingMessage(payload);
					  return processKeepAlive(payload);
					  return RegisterUserMessage.fromJson(message);
					  return processValidateAuthTokenMessage(headerpayload);
					  // return ValidateAuthTokenMessage.fromJson(message);
					return UserConnectedToGlobalAudio.fromJson(message);
					return UserDisconnectedFromGlobalAudio.fromJson(message);
					return new GetAllMeetingsRequest("the_string_is_not_used_anywhere");
				}
			}
		}
		return null;
	}
		String userid = payload.get(.).getAsString();
		String authToken = payload.get(.).getAsString();
		String replyTo = header.get(.).getAsString();
		String sessionId = "tobeimplemented";
		return new ValidateAuthTokenMessage(iduseridauthTokenreplyTo,
		    sessionId);
	}
	private static IPublishedMessage processCreateMeeting(JsonObject payload) {
		String name = payload.get(.).getAsString();
		Boolean record = payload.get(.).getAsBoolean();
		String voiceBridge = payload.get(.).getAsString();
		Long duration = payload.get(.).getAsLong();
		Boolean autoStartRecording = payload.get(.).getAsBoolean();
		Boolean allowStartStopRecording = payload.get(.).getAsBoolean();
		String moderatorPassword = payload.get(.).getAsString();
		String viewerPassword = payload.get(.).getAsString();
		Long createTime = payload.get(.).getAsLong();
		String createDate = payload.get(.).getAsString();
		return new CreateMeetingMessage(idexternalIdnamerecordvoiceBridge
				          durationautoStartRecordingallowStartStopRecording,
				          moderatorPasswordviewerPasswordcreateTimecreateDate);
	}
	private static IPublishedMessage processDestroyMeeting(JsonObject payload) {
		return new DestroyMeetingMessage(id);
	}
		return new EndMeetingMessage(id);
	}	
	private static IPublishedMessage processKeepAlive(JsonObject payload) {
		return new KeepAliveMessage(id);
	}
New to GrepCode? Check out our FAQ X