use of com.google.gson.JsonParser 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.JsonParser 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;
}
}
}
}
use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.
the class CaptionClientMessageSender method handleCaptionMessage.
public void handleCaptionMessage(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 SendCaptionHistoryReplyMessage.SEND_CAPTION_HISTORY_REPLY:
SendCaptionHistoryReplyMessage sch = SendCaptionHistoryReplyMessage.fromJson(message);
if (sch != null) {
processSendCaptionHistoryReplyMessage(sch);
}
break;
case UpdateCaptionOwnerMessage.UPDATE_CAPTION_OWNER:
UpdateCaptionOwnerMessage uco = UpdateCaptionOwnerMessage.fromJson(message);
if (uco != null) {
processUpdateCaptionOwnerMessage(uco);
}
break;
case EditCaptionHistoryMessage.EDIT_CAPTION_HISTORY:
EditCaptionHistoryMessage ech = EditCaptionHistoryMessage.fromJson(message);
if (ech != null) {
processEditCaptionHistoryMessage(ech);
}
break;
}
}
}
}
use of com.google.gson.JsonParser in project iosched by google.
the class RemoteJsonHelper method fetchJsonFromPublicURL.
public static JsonObject fetchJsonFromPublicURL(String urlStr) throws IOException {
URL url = new URL(urlStr);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// 30 seconds
connection.setReadTimeout(1000 * 30);
int response = connection.getResponseCode();
if (response < 200 || response >= 300) {
throw new IllegalArgumentException("Unexpected HTTP response [" + response + "] at URL: " + urlStr);
}
InputStream stream = connection.getInputStream();
JsonReader reader = new JsonReader(new InputStreamReader(stream, Charset.forName("UTF-8")));
return (JsonObject) new JsonParser().parse(reader);
}
use of com.google.gson.JsonParser in project iosched by google.
the class VendorAPIEntityFetcher method fetch.
@Override
public JsonElement fetch(Enum<?> entityType, Map<String, String> params) throws IOException {
StringBuilder urlStr = new StringBuilder(BASE_URL);
urlStr.append(entityType.name());
if (params != null && !params.isEmpty()) {
urlStr.append("?");
for (Map.Entry<String, String> param : params.entrySet()) {
urlStr.append(param.getKey()).append("=").append(param.getValue()).append("&");
}
urlStr.deleteCharAt(urlStr.length() - 1);
}
URL url = new URL(urlStr.toString());
if (LOG.isLoggable(Level.INFO)) {
LOG.info("URL requested: " + url);
}
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// 30 seconds
connection.setReadTimeout(1000 * 30);
connection.setRequestProperty("code", Config.CMS_API_CODE);
connection.setRequestProperty("apikey", Config.CMS_API_KEY);
InputStream stream = connection.getInputStream();
JsonReader reader = new JsonReader(new InputStreamReader(stream, Charset.forName("UTF-8")));
return new JsonParser().parse(reader);
}
Aggregations