Search in sources :

Example 1 with StartCustomPollRequestMessage

use of org.bigbluebutton.common.messages.StartCustomPollRequestMessage in project bigbluebutton by bigbluebutton.

the class FromJsonDecoder method decodeMessage.

public IBigBlueButtonMessage decodeMessage(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();
            if (PubSubPingMessage.PUBSUB_PING.equals(messageName)) {
                Gson gson = new Gson();
                PubSubPingMessage msg = gson.fromJson(message, PubSubPingMessage.class);
                return msg;
            } else if (PubSubPongMessage.PUBSUB_PONG.equals(messageName)) {
                Gson gson = new Gson();
                PubSubPongMessage msg = gson.fromJson(message, PubSubPongMessage.class);
                return msg;
            } else if (StartCustomPollRequestMessage.START_CUSTOM_POLL_REQUEST.equals(messageName)) {
                Gson gson = new Gson();
                StartCustomPollRequestMessage msg = gson.fromJson(message, StartCustomPollRequestMessage.class);
                return msg;
            } else {
                // System.out.println("Unknown message name=[" + messageName + "]");
                return null;
            }
        }
    }
    System.out.println("Invalid message format");
    return null;
}
Also used : PubSubPongMessage(org.bigbluebutton.common.messages.PubSubPongMessage) PubSubPingMessage(org.bigbluebutton.common.messages.PubSubPingMessage) JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson) StartCustomPollRequestMessage(org.bigbluebutton.common.messages.StartCustomPollRequestMessage) JsonParser(com.google.gson.JsonParser)

Aggregations

Gson (com.google.gson.Gson)1 JsonObject (com.google.gson.JsonObject)1 JsonParser (com.google.gson.JsonParser)1 PubSubPingMessage (org.bigbluebutton.common.messages.PubSubPingMessage)1 PubSubPongMessage (org.bigbluebutton.common.messages.PubSubPongMessage)1 StartCustomPollRequestMessage (org.bigbluebutton.common.messages.StartCustomPollRequestMessage)1