Search in sources :

Example 31 with Gson

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

the class UserClientMessageSender method processUpdateBreakoutUsers.

private void processUpdateBreakoutUsers(UpdateBreakoutUsers msg) {
    Map<String, Object> args = new HashMap<String, Object>();
    args.put("parentMeetingId", msg.payload.parentMeetingId);
    args.put("breakoutMeetingId", msg.payload.breakoutMeetingId);
    args.put("users", msg.payload.users);
    Map<String, Object> message = new HashMap<String, Object>();
    Gson gson = new Gson();
    message.put("msg", gson.toJson(args));
    BroadcastClientMessage m = new BroadcastClientMessage(msg.payload.parentMeetingId, "updateBreakoutUsers", message);
    service.sendMessage(m);
}
Also used : BroadcastClientMessage(org.bigbluebutton.red5.client.messaging.BroadcastClientMessage) HashMap(java.util.HashMap) Gson(com.google.gson.Gson) JsonObject(com.google.gson.JsonObject)

Example 32 with Gson

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

the class AbstractService method addHeaderToMessage.

public String addHeaderToMessage(String jsonMessage, String messageName) {
    JsonObject payload = JsonEncoderUtil.buildPayload(jsonMessage);
    JsonObject header = JsonEncoderUtil.addMessageHeader(messageName);
    return new Gson().toJson(JsonEncoderUtil.headerAndPayload(header, payload));
}
Also used : JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson)

Example 33 with Gson

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

the class BigBlueButtonApplication method roomDisconnect.

@Override
public void roomDisconnect(IConnection conn) {
    String remoteHost = Red5.getConnectionLocal().getRemoteAddress();
    int remotePort = Red5.getConnectionLocal().getRemotePort();
    BigBlueButtonSession bbbSession = (BigBlueButtonSession) Red5.getConnectionLocal().getAttribute(Constants.SESSION);
    String meetingId = bbbSession.getRoom();
    String userId = bbbSession.getInternalUserID();
    String connType = getConnectionType(Red5.getConnectionLocal().getType());
    String userFullname = bbbSession.getUsername();
    String connId = Red5.getConnectionLocal().getSessionId();
    String clientId = Red5.getConnectionLocal().getClient().getId();
    String sessionId = CONN + userId;
    Map<String, Object> logData = new HashMap<String, Object>();
    logData.put("meetingId", meetingId);
    logData.put("connType", connType);
    logData.put("connId", connId);
    logData.put("clientId", clientId);
    logData.put("remoteAddress", remoteHost + ":" + remotePort);
    logData.put("sessionId", sessionId);
    logData.put("userId", userId);
    logData.put("username", userFullname);
    logData.put("event", "user_leaving_bbb_apps");
    logData.put("description", "User leaving BBB Apps.");
    Gson gson = new Gson();
    String logStr = gson.toJson(logData);
    boolean removeUser = userConnections.userDisconnected(userId, connId);
    if (removeUser) {
        log.info("User leaving bbb-apps: data={}", logStr);
        red5InGW.userLeft(bbbSession.getRoom(), getBbbSession().getInternalUserID(), sessionId);
    } else {
        log.info("User not leaving bbb-apps but just disconnected: data={}", logStr);
    }
    super.roomDisconnect(conn);
}
Also used : HashMap(java.util.HashMap) Gson(com.google.gson.Gson)

Example 34 with Gson

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

the class BigBlueButtonApplication method getHeapStatsHelper.

private void getHeapStatsHelper() {
    int mb = 1024 * 1024;
    // Getting the runtime reference from system
    Runtime runtime = Runtime.getRuntime();
    long usedMemory = (runtime.totalMemory() - runtime.freeMemory()) / mb;
    long freeMemory = runtime.freeMemory() / mb;
    long totalMemory = runtime.totalMemory() / mb;
    long maxMemory = runtime.maxMemory() / mb;
    Map<String, Object> logData = new HashMap<String, Object>();
    logData.put("used", usedMemory);
    logData.put("free", freeMemory);
    logData.put("total", totalMemory);
    logData.put("max", maxMemory);
    Gson gson = new Gson();
    String logStr = gson.toJson(logData);
    log.info("JVM Heap [MB] data={}", logStr);
}
Also used : HashMap(java.util.HashMap) Gson(com.google.gson.Gson)

Example 35 with Gson

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

the class CaptionClientMessageSender method processSendCaptionHistoryReplyMessage.

private void processSendCaptionHistoryReplyMessage(SendCaptionHistoryReplyMessage msg) {
    Map<String, Object> message = new HashMap<String, Object>();
    Gson gson = new Gson();
    message.put("msg", gson.toJson(msg.captionHistory));
    DirectClientMessage m = new DirectClientMessage(msg.meetingID, msg.requesterID, "sendCaptionHistoryReply", message);
    service.sendMessage(m);
}
Also used : HashMap(java.util.HashMap) Gson(com.google.gson.Gson) JsonObject(com.google.gson.JsonObject) DirectClientMessage(org.bigbluebutton.red5.client.messaging.DirectClientMessage)

Aggregations

Gson (com.google.gson.Gson)1309 Test (org.junit.Test)280 HashMap (java.util.HashMap)227 GsonBuilder (com.google.gson.GsonBuilder)174 JsonObject (com.google.gson.JsonObject)157 IOException (java.io.IOException)147 CommandWrapper (ClientServerApi.CommandWrapper)123 ArrayList (java.util.ArrayList)121 CommandExecuter (CommandHandler.CommandExecuter)119 CriticalError (SQLDatabase.SQLDatabaseException.CriticalError)118 JsonSyntaxException (com.google.gson.JsonSyntaxException)103 ClientNotConnected (SQLDatabase.SQLDatabaseException.ClientNotConnected)96 JsonElement (com.google.gson.JsonElement)78 Type (java.lang.reflect.Type)77 Map (java.util.Map)63 ProductNotExistInCatalog (SQLDatabase.SQLDatabaseException.ProductNotExistInCatalog)53 SmartCode (BasicCommonClasses.SmartCode)50 InputStreamReader (java.io.InputStreamReader)49 List (java.util.List)49 TypeToken (com.google.gson.reflect.TypeToken)44