Java Code Examples for com.github.openjson.JSONObject#getInt()
The following examples show how to use
com.github.openjson.JSONObject#getInt() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestStreamProcessor.java From openmeetings with Apache License 2.0 | 5 votes |
void onMessage(IWsClient c, final String cmdId, JSONObject msg) { KTestStream user = getByUid(c.getUid()); switch (cmdId) { case "wannaRecord": WebSocketHelper.sendClient(c, newTestKurentoMsg() .put("id", "canRecord") .put(PARAM_ICE, kHandler.getTurnServers(null, true)) ); break; case "record": if (user != null) { user.release(this); } user = new KTestStream(c, msg, createTestPipeline()); streamByUid.put(c.getUid(), user); break; case "iceCandidate": JSONObject candidate = msg.getJSONObject(PARAM_CANDIDATE); if (user != null) { IceCandidate cand = new IceCandidate(candidate.getString(PARAM_CANDIDATE), candidate.getString("sdpMid"), candidate.getInt("sdpMLineIndex")); user.addCandidate(cand); } break; case "wannaPlay": WebSocketHelper.sendClient(c, newTestKurentoMsg() .put("id", "canPlay") .put(PARAM_ICE, kHandler.getTurnServers(null, true)) ); break; case "play": if (user != null) { user.play(c, msg, createTestPipeline()); } break; default: //no-op break; } }
Example 2
Source File: DtoHelper.java From openmeetings with Apache License 2.0 | 4 votes |
public static Integer optInt(JSONObject o, String key) { return o.has(key) && !o.isNull(key) ? o.getInt(key) : null; }
Example 3
Source File: StreamProcessor.java From openmeetings with Apache License 2.0 | 4 votes |
void onMessage(Client c, final String cmdId, JSONObject msg) { final String uid = msg.optString("uid"); KStream sender; StreamDesc sd; Optional<StreamDesc> osd; log.debug("Incoming message from user with ID '{}': {}", c.getUserId(), msg); switch (cmdId) { case "devicesAltered": sd = c.getStream(uid); if (sd != null) { if (!msg.getBoolean("audio") && c.hasActivity(Activity.AUDIO)) { c.remove(Activity.AUDIO); } if (!msg.getBoolean("video") && c.hasActivity(Activity.VIDEO)) { c.remove(Activity.VIDEO); } sd.setActivities(); WebSocketHelper.sendRoom(new TextRoomMessage(c.getRoomId(), cm.update(c), RoomMessage.Type.RIGHT_UPDATED, c.getUid())); } break; case "toggleActivity": toggleActivity(c, Activity.valueOf(msg.getString("activity"))); break; case "broadcastStarted": handleBroadcastStarted(c, uid, msg); break; case "onIceCandidate": sender = getByUid(uid); if (sender != null) { JSONObject candidate = msg.getJSONObject(PARAM_CANDIDATE); String candStr = candidate.getString(PARAM_CANDIDATE); if (!Strings.isEmpty(candStr)) { IceCandidate cand = new IceCandidate( candStr , candidate.getString("sdpMid") , candidate.getInt("sdpMLineIndex")); sender.addCandidate(cand, msg.getString("luid")); } } break; case "addListener": sender = getByUid(msg.getString("sender")); if (sender != null) { Client sendClient = cm.getBySid(sender.getSid()); sd = sendClient.getStream(sender.getUid()); if (sd == null) { break; } if (StreamType.SCREEN == sd.getType() && sd.hasActivity(Activity.RECORD) && !sd.hasActivity(Activity.SCREEN)) { break; } sender.addListener(this, c.getSid(), c.getUid(), msg.getString("sdpOffer")); } break; case "wannaShare": osd = c.getScreenStream(); if (screenShareAllowed(c) || (osd.isPresent() && !osd.get().hasActivity(Activity.SCREEN))) { startSharing(c, osd, msg, Activity.SCREEN); } break; case "wannaRecord": osd = c.getScreenStream(); if (recordingAllowed(c)) { Room r = c.getRoom(); if (Room.Type.INTERVIEW == r.getType()) { log.warn("This shouldn't be called for interview room"); break; } boolean sharing = isSharing(r.getId()); startSharing(c, osd, msg, Activity.RECORD); if (sharing) { startRecording(c); } } break; case "pauseSharing": pauseSharing(c, uid); break; case "stopRecord": stopRecording(c); break; case "errorSharing": errorSharing(c); break; default: // no-op break; } }