use of com.google.gson.Gson in project bigbluebutton by bigbluebutton.
the class WhiteboardClientMessageSender method processIsWhiteboardEnabledReply.
private void processIsWhiteboardEnabledReply(IsWhiteboardEnabledReplyMessage msg) {
Map<String, Object> args = new HashMap<String, Object>();
args.put("enabled", msg.enabled);
Map<String, Object> message = new HashMap<String, Object>();
Gson gson = new Gson();
message.put("msg", gson.toJson(args));
DirectClientMessage m = new DirectClientMessage(msg.meetingId, msg.requesterId, "WhiteboardIsWhiteboardEnabledReply", message);
service.sendMessage(m);
// broadcast message
BroadcastClientMessage b = new BroadcastClientMessage(msg.meetingId, "WhiteboardIsWhiteboardEnabledReply", message);
service.sendMessage(b);
}
use of com.google.gson.Gson in project bigbluebutton by bigbluebutton.
the class WhiteboardClientMessageSender method processSendWhiteboardAnnotationReplyMessage.
private void processSendWhiteboardAnnotationReplyMessage(SendWhiteboardAnnotationReplyMessage msg) {
Map<String, Object> args = new HashMap<String, Object>();
args.put("whiteboardId", msg.whiteboardId);
Map<String, Object> shape = new HashMap<String, Object>();
shape.put("id", msg.shape.get("id"));
shape.put("type", msg.shape.get("type"));
shape.put("status", msg.shape.get("status"));
shape.put("shape", msg.shape.get("shapes"));
args.put("shape", shape);
Map<String, Object> message = new HashMap<String, Object>();
Gson gson = new Gson();
message.put("msg", gson.toJson(args));
//broadcast message
BroadcastClientMessage b = new BroadcastClientMessage(msg.meetingId, "WhiteboardNewAnnotationCommand", message);
service.sendMessage(b);
}
use of com.google.gson.Gson in project bigbluebutton by bigbluebutton.
the class WhiteboardClientMessageSender method processClearWhiteboardReply.
private void processClearWhiteboardReply(ClearWhiteboardReplyMessage msg) {
Map<String, Object> args = new HashMap<String, Object>();
args.put("whiteboardId", msg.whiteboardId);
Map<String, Object> message = new HashMap<String, Object>();
Gson gson = new Gson();
message.put("msg", gson.toJson(args));
BroadcastClientMessage m = new BroadcastClientMessage(msg.meetingId, "WhiteboardClearCommand", message);
service.sendMessage(m);
}
use of com.google.gson.Gson in project bigbluebutton by bigbluebutton.
the class ConnectionInvokerService method sendDirectMessage.
private void sendDirectMessage(final DirectClientMessage msg) {
if (log.isTraceEnabled()) {
Gson gson = new Gson();
String json = gson.toJson(msg.getMessage());
log.trace("Handle direct message: " + msg.getMessageName() + " msg=" + json);
}
final String userId = msg.getUserID();
Runnable sender = new Runnable() {
public void run() {
IScope meetingScope = getScope(msg.getMeetingID());
if (meetingScope != null) {
IConnection conn = getConnection(meetingScope, userId);
if (conn != null) {
if (conn.isConnected()) {
List<Object> params = new ArrayList<Object>();
params.add(msg.getMessageName());
params.add(msg.getMessage());
if (log.isTraceEnabled()) {
Gson gson = new Gson();
String json = gson.toJson(msg.getMessage());
log.debug("Send direct message: " + msg.getMessageName() + " msg=" + json);
}
ServiceUtils.invokeOnConnection(conn, "onMessageFromServer", params.toArray());
}
} else {
log.info("Cannot send message=[" + msg.getMessageName() + "] to [" + userId + "] as no such session on meeting=[" + msg.getMeetingID() + "]");
}
}
}
};
/**
* We need to add a way to cancel sending when the thread is blocked.
* Red5 uses a semaphore to guard the rtmp connection and we've seen
* instances where our thread is blocked preventing us from sending messages
* to other connections. (ralam nov 19, 2015)
*/
long endNanos = System.nanoTime() + SEND_TIMEOUT;
Future<?> f = runExec.submit(sender);
try {
// Only wait for the remaining time budget
long timeLeft = endNanos - System.nanoTime();
f.get(timeLeft, TimeUnit.NANOSECONDS);
} catch (ExecutionException e) {
log.warn("ExecutionException while sending direct message on connection[" + userId + "]");
log.warn("ExcecutionException cause: " + e.getMessage());
} catch (InterruptedException e) {
log.warn("Interrupted exception while sending direct message on connection[" + userId + "]");
Thread.currentThread().interrupt();
} catch (TimeoutException e) {
log.warn("Timeout exception while sending direct message on connection[" + userId + "]");
f.cancel(true);
}
}
use of com.google.gson.Gson in project LoganSquare by bluelinelabs.
the class MainActivity method performSerializeTests.
private void performSerializeTests() {
mBarChart.clear();
mBarChart.setSections(new String[] { "Serialize 60 items", "Serialize 20 items", "Serialize 7 items", "Serialize 2 items" });
Gson gson = new Gson();
ObjectMapper objectMapper = new ObjectMapper();
Moshi moshi = new Moshi.Builder().build();
List<Serializer> serializers = new ArrayList<>();
for (Response response : mResponsesToSerialize) {
for (int iteration = 0; iteration < ITERATIONS; iteration++) {
serializers.add(new GsonSerializer(mSerializeListener, response, gson));
serializers.add(new JacksonDatabindSerializer(mSerializeListener, response, objectMapper));
serializers.add(new LoganSquareSerializer(mSerializeListener, response));
serializers.add(new MoshiSerializer(mSerializeListener, response, moshi));
}
}
for (Serializer serializer : serializers) {
serializer.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
}
}
Aggregations