Java Code Examples for org.kurento.jsonrpc.message.Request#getParams()
The following examples show how to use
org.kurento.jsonrpc.message.Request#getParams() .
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: DemoJsonRpcUserControl.java From kurento-room with Apache License 2.0 | 6 votes |
@Override public void customRequest(Transaction transaction, Request<JsonObject> request, ParticipantRequest participantRequest) { try { if (request.getParams() == null || request.getParams().get(filterType.getCustomRequestParam()) == null) { throw new RuntimeException( "Request element '" + filterType.getCustomRequestParam() + "' is missing"); } switch (filterType) { case MARKER: handleMarkerRequest(transaction, request, participantRequest); break; case HAT: default: handleHatRequest(transaction, request, participantRequest); } } catch (Exception e) { log.error("Unable to handle custom request", e); try { transaction.sendError(e); } catch (IOException e1) { log.warn("Unable to send error response", e1); } } }
Example 2
Source File: BidirectionalMultiTest.java From kurento-java with Apache License 2.0 | 6 votes |
@Override public void handleRequest(Transaction transaction, Request<Integer> request) throws Exception { log.debug("Request id:" + request.getId()); log.debug("Request method:" + request.getMethod()); log.debug("Request params:" + request.getParams()); transaction.sendResponse(request.getParams()); final Session session = transaction.getSession(); final Object params = request.getParams(); new Thread() { @Override public void run() { asyncReverseSend(session, params); } }.start(); }
Example 3
Source File: BidirectionalTest.java From kurento-java with Apache License 2.0 | 6 votes |
@Override public void handleRequest(Transaction transaction, Request<Object> request) throws Exception { log.debug("Request id:" + request.getId()); log.debug("Request method:" + request.getMethod()); log.debug("Request params:" + request.getParams()); transaction.sendResponse(request.getParams()); final Session session = transaction.getSession(); final Object params = request.getParams(); new Thread() { @Override public void run() { asyncReverseSend(session, params); } }.start(); }
Example 4
Source File: JsonRpcAndJavaMethodManager.java From kurento-java with Apache License 2.0 | 6 votes |
private Object[] calculateParamValues(Session session, Method m, Request<JsonObject> request) { JsonObject params = request.getParams(); String[] parameterNames = paranamer.lookupParameterNames(m, true); Type[] parameterTypes = m.getGenericParameterTypes(); Object[] values = new Object[parameterTypes.length]; for (int i = 0; i < parameterTypes.length; i++) { values[i] = getValueFromParam(session, m, params, parameterNames[i], parameterTypes[i]); } if (log.isInfoEnabled()) { StringBuilder sb = new StringBuilder("["); for (int i = 0; i < parameterNames.length; i++) { sb.append(parameterNames[i] + "(" + parameterTypes[i] + ")=" + values[i] + ","); } sb.append("]"); log.debug("Executing method {} with params {}", m.getName(), params); } return values; }
Example 5
Source File: ProtocolManager.java From kurento-java with Apache License 2.0 | 6 votes |
private void processPingMessage(ServerSessionFactory factory, Request<JsonElement> request, ResponseSender responseSender, String transportId) throws IOException { if (maxHeartbeats == 0 || maxHeartbeats > ++heartbeats) { long interval = -1; if (request.getParams() != null) { JsonObject element = (JsonObject) request.getParams(); if (element.has(INTERVAL_PROPERTY)) { interval = element.get(INTERVAL_PROPERTY).getAsLong(); } } pingWachdogManager.pingReceived(transportId, interval); String sessionId = request.getSessionId(); JsonObject pongPayload = new JsonObject(); pongPayload.add(PONG_PAYLOAD, new JsonPrimitive(PONG)); responseSender.sendPingResponse(new Response<>(sessionId, request.getId(), pongPayload)); } }
Example 6
Source File: JsonRoomUtils.java From openvidu with Apache License 2.0 | 5 votes |
public static <T> T getRequestParam(Request<JsonObject> request, String paramName, Class<T> type, boolean allowNull) { JsonObject params = request.getParams(); if (params == null) { if (!allowNull) { throw new OpenViduException(Code.TRANSPORT_REQUEST_ERROR_CODE, "Invalid request lacking parameter '" + paramName + "'"); } else { return null; } } return getConverted(params.get(paramName), paramName, type, allowNull); }
Example 7
Source File: RpcHandler.java From openvidu with Apache License 2.0 | 5 votes |
public static String getStringParam(Request<JsonObject> request, String key) { if (request.getParams() == null || request.getParams().get(key) == null) { throw new RuntimeException("Request element '" + key + "' is missing in method '" + request != null ? request.getMethod() : "[NO REQUEST OBJECT]" + "'. CHECK THAT 'openvidu-server' AND 'openvidu-browser' SHARE THE SAME VERSION NUMBER"); } return request.getParams().get(key).getAsString(); }
Example 8
Source File: RpcHandler.java From openvidu with Apache License 2.0 | 5 votes |
public static int getIntParam(Request<JsonObject> request, String key) { if (request.getParams() == null || request.getParams().get(key) == null) { throw new RuntimeException("Request element '" + key + "' is missing in method '" + request.getMethod() + "'. CHECK THAT 'openvidu-server' AND 'openvidu-browser' SHARE THE SAME VERSION NUMBER"); } return request.getParams().get(key).getAsInt(); }
Example 9
Source File: RpcHandler.java From openvidu with Apache License 2.0 | 5 votes |
public static boolean getBooleanParam(Request<JsonObject> request, String key) { if (request.getParams() == null || request.getParams().get(key) == null) { throw new RuntimeException("Request element '" + key + "' is missing in method '" + request.getMethod() + "'. CHECK THAT 'openvidu-server' AND 'openvidu-browser' SHARE THE SAME VERSION NUMBER"); } return request.getParams().get(key).getAsBoolean(); }
Example 10
Source File: RpcHandler.java From openvidu with Apache License 2.0 | 5 votes |
public static JsonElement getParam(Request<JsonObject> request, String key) { if (request.getParams() == null || request.getParams().get(key) == null) { throw new RuntimeException("Request element '" + key + "' is missing in method '" + request.getMethod() + "'. CHECK THAT 'openvidu-server' AND 'openvidu-browser' SHARE THE SAME VERSION NUMBER"); } return request.getParams().get(key); }
Example 11
Source File: JsonRoomUtils.java From kurento-room with Apache License 2.0 | 5 votes |
public static <T> T getRequestParam(Request<JsonObject> request, String paramName, Class<T> type, boolean allowNull) { JsonObject params = request.getParams(); if (params == null) { if (!allowNull) { throw new RoomException(Code.TRANSPORT_REQUEST_ERROR_CODE, "Invalid request lacking parameter '" + paramName + "'"); } else { return null; } } return getConverted(params.get(paramName), paramName, type, allowNull); }
Example 12
Source File: JsonRpcUserControl.java From kurento-room with Apache License 2.0 | 4 votes |
public static String getStringParam(Request<JsonObject> request, String key) { if (request.getParams() == null || request.getParams().get(key) == null) { throw new RuntimeException("Request element '" + key + "' is missing"); } return request.getParams().get(key).getAsString(); }
Example 13
Source File: JsonRpcUserControl.java From kurento-room with Apache License 2.0 | 4 votes |
public static int getIntParam(Request<JsonObject> request, String key) { if (request.getParams() == null || request.getParams().get(key) == null) { throw new RuntimeException("Request element '" + key + "' is missing"); } return request.getParams().get(key).getAsInt(); }
Example 14
Source File: JsonRpcUserControl.java From kurento-room with Apache License 2.0 | 4 votes |
public static boolean getBooleanParam(Request<JsonObject> request, String key) { if (request.getParams() == null || request.getParams().get(key) == null) { throw new RuntimeException("Request element '" + key + "' is missing"); } return request.getParams().get(key).getAsBoolean(); }