Search in sources :

Example 76 with JsonParser

use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.

the class CaptionMessageReceiver method handleMessage.

@Override
public void handleMessage(String pattern, String channel, String message) {
    if (channel.equalsIgnoreCase(MessagingConstants.TO_CAPTION_CHANNEL)) {
        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 (SendCaptionHistoryRequestMessage.SEND_CAPTION_HISTORY_REQUEST.equals(messageName)) {
                    SendCaptionHistoryRequestMessage msg = SendCaptionHistoryRequestMessage.fromJson(message);
                    bbbGW.sendCaptionHistory(msg.meetingID, msg.requesterID);
                } else if (UpdateCaptionOwnerMessage.UPDATE_CAPTION_OWNER.equals(messageName)) {
                    UpdateCaptionOwnerMessage msg = UpdateCaptionOwnerMessage.fromJson(message);
                    bbbGW.updateCaptionOwner(msg.meetingID, msg.locale, msg.localeCode, msg.ownerID);
                } else if (EditCaptionHistoryMessage.EDIT_CAPTION_HISTORY.equals(messageName)) {
                    EditCaptionHistoryMessage msg = EditCaptionHistoryMessage.fromJson(message);
                    bbbGW.editCaptionHistory(msg.meetingID, msg.userID, msg.startIndex, msg.endIndex, msg.locale, msg.localeCode, msg.text);
                }
            }
        }
    }
}
Also used : SendCaptionHistoryRequestMessage(org.bigbluebutton.common.messages.SendCaptionHistoryRequestMessage) UpdateCaptionOwnerMessage(org.bigbluebutton.common.messages.UpdateCaptionOwnerMessage) JsonObject(com.google.gson.JsonObject) EditCaptionHistoryMessage(org.bigbluebutton.common.messages.EditCaptionHistoryMessage) JsonParser(com.google.gson.JsonParser)

Example 77 with JsonParser

use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.

the class DeskShareMessageReceiver method handleMessage.

@Override
public void handleMessage(String pattern, String channel, String message) {
    if (channel.equalsIgnoreCase(MessagingConstants.FROM_VOICE_CONF_SYSTEM_CHAN)) {
        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 (DeskShareStartedEventMessage.DESKSHARE_STARTED_MESSAGE.equals(messageName)) {
                    DeskShareStartedEventMessage msg = DeskShareStartedEventMessage.fromJson(message);
                    log.info("^^^^^^^DESKSHARE STARTED^^^^^^");
                    bbbGW.deskShareStarted(msg.conferenceName, msg.callerId, msg.callerIdName);
                } else if (DeskShareStoppedEventMessage.DESK_SHARE_STOPPED_MESSAGE.equals(messageName)) {
                    DeskShareStoppedEventMessage msg = DeskShareStoppedEventMessage.fromJson(message);
                    log.info("^^^^^^^DESKSHARE STOPPED^^^^^^");
                    bbbGW.deskShareStopped(msg.conferenceName, msg.callerId, msg.callerIdName);
                } else if (DeskShareRTMPBroadcastStartedEventMessage.DESKSHARE_RTMP_BROADCAST_STARTED_MESSAGE.equals(messageName)) {
                    log.info("^^^^^^^DESKSHARE_RTMP_BROADCAST_STARTED_MESSAGE^^^^^^");
                    DeskShareRTMPBroadcastStartedEventMessage msg = DeskShareRTMPBroadcastStartedEventMessage.fromJson(message);
                    bbbGW.deskShareRTMPBroadcastStarted(msg.conferenceName, msg.streamname, msg.vw, msg.vh, msg.timestamp);
                } else if (DeskShareRTMPBroadcastStoppedEventMessage.DESKSHARE_RTMP_BROADCAST_STOPPED_MESSAGE.equals(messageName)) {
                    log.info("^^^^^^^DESKSHARE_RTMP_BROADCAST_STOPPED_MESSAGE^^^^^^");
                    DeskShareRTMPBroadcastStoppedEventMessage msg = DeskShareRTMPBroadcastStoppedEventMessage.fromJson(message);
                    bbbGW.deskShareRTMPBroadcastStopped(msg.conferenceName, msg.streamname, msg.vw, msg.vh, msg.timestamp);
                } else if (DeskShareGetInfoRequestMessage.GET_DESKTOP_SHARE_GET_INFO_REQUEST.equals(messageName)) {
                    log.info("^^^^^^^GET_DESKTOP_SHARE_INFO_REQUEST^^^^^^");
                    DeskShareGetInfoRequestMessage msg = DeskShareGetInfoRequestMessage.fromJson(message);
                    bbbGW.deskShareGetInfoRequest(msg.meetingId, msg.requesterId, msg.replyTo);
                }
            }
        }
    }
}
Also used : DeskShareStartedEventMessage(org.bigbluebutton.common.messages.DeskShareStartedEventMessage) DeskShareStoppedEventMessage(org.bigbluebutton.common.messages.DeskShareStoppedEventMessage) DeskShareGetInfoRequestMessage(org.bigbluebutton.common.messages.DeskShareGetInfoRequestMessage) DeskShareRTMPBroadcastStartedEventMessage(org.bigbluebutton.common.messages.DeskShareRTMPBroadcastStartedEventMessage) JsonObject(com.google.gson.JsonObject) DeskShareRTMPBroadcastStoppedEventMessage(org.bigbluebutton.common.messages.DeskShareRTMPBroadcastStoppedEventMessage) JsonParser(com.google.gson.JsonParser)

Example 78 with JsonParser

use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.

the class LockMessageReceiver method handleMessage.

@Override
public void handleMessage(String pattern, String channel, String message) {
    if (channel.equalsIgnoreCase(MessagingConstants.TO_MEETING_CHANNEL)) {
        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 (GetLockSettingsMessage.GET_LOCK_SETTINGS.equals(messageName)) {
                    GetLockSettingsMessage msg = GetLockSettingsMessage.fromJson(message);
                    bbbGW.getLockSettings(msg.meetingId, msg.userId);
                } else if (LockUserMessage.LOCK_USER.equals(messageName)) {
                    LockUserMessage msg = LockUserMessage.fromJson(message);
                    bbbGW.lockUser(msg.meetingId, msg.requesterId, msg.lock, msg.internalUserId);
                } else if (SendLockSettingsMessage.SEND_LOCK_SETTINGS.equals(messageName)) {
                    SendLockSettingsMessage msg = SendLockSettingsMessage.fromJson(message);
                    bbbGW.sendLockSettings(msg.meetingId, msg.userId, msg.newSettings);
                }
            }
        }
    }
}
Also used : LockUserMessage(org.bigbluebutton.common.messages.LockUserMessage) GetLockSettingsMessage(org.bigbluebutton.common.messages.GetLockSettingsMessage) JsonObject(com.google.gson.JsonObject) SendLockSettingsMessage(org.bigbluebutton.common.messages.SendLockSettingsMessage) JsonParser(com.google.gson.JsonParser)

Example 79 with JsonParser

use of com.google.gson.JsonParser in project bigbluebutton by bigbluebutton.

the class PollingMessageReceiver method handleMessage.

@Override
public void handleMessage(String pattern, String channel, String message) {
    if (channel.equalsIgnoreCase(MessagingConstants.TO_POLLING_CHANNEL)) {
        log.debug("Polling message: " + channel + " " + 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 (VotePollUserRequestMessage.VOTE_POLL_REQUEST.equals(messageName)) {
                    VotePollUserRequestMessage msg = VotePollUserRequestMessage.fromJson(message);
                    bbbGW.votePoll(msg.meetingId, msg.userId, msg.pollId, msg.questionId, msg.answerId);
                } else if (StartPollRequestMessage.START_POLL_REQUEST.equals(messageName)) {
                    log.debug("Received StartPollRequest message");
                    StartPollRequestMessage msg = StartPollRequestMessage.fromJson(message);
                    bbbGW.startPoll(msg.meetingId, msg.requesterId, msg.pollId, msg.pollType);
                } else if (StopPollRequestMessage.STOP_POLL_REQUEST.equals(messageName)) {
                    StopPollRequestMessage msg = StopPollRequestMessage.fromJson(message);
                    bbbGW.stopPoll(msg.meetingId, msg.requesterId, msg.pollId);
                } else if (ShowPollResultRequestMessage.SHOW_POLL_RESULT_REQUEST.equals(messageName)) {
                    ShowPollResultRequestMessage msg = ShowPollResultRequestMessage.fromJson(message);
                    bbbGW.showPollResult(msg.meetingId, msg.requesterId, msg.pollId, msg.show);
                } else if (StartCustomPollRequestMessage.START_CUSTOM_POLL_REQUEST.equals(messageName)) {
                    Gson gson = new Gson();
                    StartCustomPollRequestMessage msg = gson.fromJson(message, StartCustomPollRequestMessage.class);
                    bbbGW.handleBigBlueButtonMessage(msg);
                }
            }
        }
    }
}
Also used : JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) JsonParser(com.google.gson.JsonParser)

Example 80 with JsonParser

use of com.google.gson.JsonParser in project Presentation by feelinglucky.

the class PstRequest method getPinsFromResponse.

private int getPinsFromResponse(String response) {
    JsonObject jsonObject = (JsonObject) new JsonParser().parse(response);
    JsonArray jsonArrayPins = jsonObject.getAsJsonArray("pins");
    mAffectedRows = 0;
    for (int i = 0; i < jsonArrayPins.size(); i++) {
        JsonObject tmp = (JsonObject) jsonArrayPins.get(i);
        Pin pin = mGson.fromJson(tmp, Pin.class);
        Pin.File file = mGson.fromJson(tmp.getAsJsonObject("file"), Pin.File.class);
        pin.setKey(file.key);
        pin.setWidth(file.width);
        pin.setHeight(file.height);
        // ignore gif and some 'bad' images.
        if (file.frames == 1 && (file.width / (float) file.height < .38f)) {
            try {
                Dao.CreateOrUpdateStatus status = mDatabaseHelper.getPinsDAO().createOrUpdate(pin);
                mAffectedRows += status.getNumLinesChanged();
            } catch (SQLException e) {
                Logger.e(e.getMessage());
            }
        }
    }
    mListener.onSaved(mAffectedRows);
    return mAffectedRows;
}
Also used : JsonArray(com.google.gson.JsonArray) Dao(com.j256.ormlite.dao.Dao) Pin(com.gracecode.android.presentation.dao.Pin) SQLException(java.sql.SQLException) JsonObject(com.google.gson.JsonObject) JsonParser(com.google.gson.JsonParser)

Aggregations

JsonParser (com.google.gson.JsonParser)356 JsonObject (com.google.gson.JsonObject)285 JsonElement (com.google.gson.JsonElement)105 JsonArray (com.google.gson.JsonArray)57 IOException (java.io.IOException)43 Gson (com.google.gson.Gson)40 InputStreamReader (java.io.InputStreamReader)32 ArrayList (java.util.ArrayList)20 HashMap (java.util.HashMap)20 Map (java.util.Map)18 Type (java.lang.reflect.Type)15 JsonReader (com.google.gson.stream.JsonReader)12 Test (org.junit.Test)12 URL (java.net.URL)11 AssetManager (android.content.res.AssetManager)10 InputStream (java.io.InputStream)10 GsonBuilder (com.google.gson.GsonBuilder)9 UserType (com.glitchcog.fontificator.bot.UserType)8 EmojiType (com.glitchcog.fontificator.emoji.EmojiType)8 JsonParseException (com.google.gson.JsonParseException)8