Java Code Examples for org.kurento.jsonrpc.Transaction#sendResponse()

The following examples show how to use org.kurento.jsonrpc.Transaction#sendResponse() . 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 vote down vote up
private void handleHatRequest(Transaction transaction, Request<JsonObject> request,
    ParticipantRequest participantRequest) throws IOException {
  boolean filterOn = request.getParams().get(filterType.getCustomRequestParam()).getAsBoolean();
  String pid = participantRequest.getParticipantId();
  if (filterOn) {
    if (transaction.getSession().getAttributes().containsKey(SESSION_ATTRIBUTE_FILTER)) {
      throw new RuntimeException(filterType + " filter already on");
    }
    log.info("Applying {} filter to session {}", filterType, pid);

    FaceOverlayFilter filter =
        new FaceOverlayFilter.Builder(roomManager.getPipeline(pid)).build();
    filter.setOverlayedImage(this.hatUrl, this.offsetXPercent, this.offsetYPercent,
        this.widthPercent, this.heightPercent);

    addFilter(transaction, pid, filter);
  } else {
    removeFilter(transaction, pid);
  }
  transaction.sendResponse(new JsonObject());
}
 
Example 2
Source File: BidirectionalTest.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: BidirectionalMultiTest.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
@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 4
Source File: CloseSessionTest.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
@Override
public void handleRequest(final Transaction transaction, Request<String> request)
    throws Exception {

  Session session = transaction.getSession();

  if (session.isNew()) {
    transaction.sendResponse("new");
  } else {
    transaction.sendResponse("old");
  }

  if (counter == 2) {
    session.close();
  }
  counter++;
}
 
Example 5
Source File: RomServerJsonRpcHandler.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
private void handleInvokeCommand(Transaction transaction, String objectRef, String operationName,
    JsonObject operationParams) throws IOException {

  Object result = server.invoke(objectRef, operationName,
      JsonUtils.fromJson(operationParams, Props.class), Object.class);

  transaction.sendResponse(result);
}
 
Example 6
Source File: ReconnectionTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequest(final Transaction transaction, Request<String> request)
    throws Exception {

  Session session = transaction.getSession();

  if (session.isNew()) {
    transaction.sendResponse("new");
  } else {
    transaction.sendResponse("old");
  }
}
 
Example 7
Source File: ServerEventsTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequest(Transaction transaction, Request<String> request) throws Exception {

  log.debug("Request: " + request);
  transaction.sendResponse(request.getParams());
  requestLatch.countDown();
}
 
Example 8
Source File: JsonRpcNotificationService.java    From kurento-room with Apache License 2.0 5 votes vote down vote up
@Override
public void sendResponse(ParticipantRequest participantRequest, Object result) {
  Transaction t = getAndRemoveTransaction(participantRequest);
  if (t == null) {
    log.error("No transaction found for {}, unable to send result {}", participantRequest, result);
    return;
  }
  try {
    t.sendResponse(result);
  } catch (Exception e) {
    log.error("Exception responding to user ({})", participantRequest, e);
  }
}
 
Example 9
Source File: DemoJsonRpcUserControl.java    From kurento-room with Apache License 2.0 5 votes vote down vote up
private void handleMarkerRequest(final Transaction transaction, Request<JsonObject> request,
    ParticipantRequest participantRequest) throws IOException {
  Integer currentUrlIndex =
      request.getParams().get(filterType.getCustomRequestParam()).getAsInt();
  String pid = participantRequest.getParticipantId();

  roomManager.updateFilter(roomManager.getRoomManager().getRoomName(pid), MARKER_ID);

  JsonObject result = new JsonObject();
  // TODO: Change RPC to remove next index requirement
  // result.addProperty(filterType.getCustomRequestParam(), 0);
  transaction.sendResponse(result);
}
 
Example 10
Source File: EchoJsonRpcHandler.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequest(Transaction transaction, Request<JsonObject> request) throws Exception {

  if (demoBean == null) {
    throw new RuntimeException("Not autowired dependencies");
  }
  log.debug("Request id:" + request.getId());
  log.debug("Request method:" + request.getMethod());
  log.debug("Request params:" + request.getParams());

  transaction.sendResponse(request.getParams());

}
 
Example 11
Source File: RpcNotificationService.java    From openvidu with Apache License 2.0 5 votes vote down vote up
public void sendResponse(String participantPrivateId, Integer transactionId, Object result) {
	Transaction t = getAndRemoveTransaction(participantPrivateId, transactionId);
	if (t == null) {
		if (!isIpcamParticipant(participantPrivateId)) {
			log.error("No transaction {} found for paticipant with private id {}, unable to send result {}",
					transactionId, participantPrivateId, result);
		}
		return;
	}
	try {
		t.sendResponse(result);
	} catch (Exception e) {
		log.error("Exception responding to participant ({})", participantPrivateId, e);
	}
}
 
Example 12
Source File: NewSessionTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequest(final Transaction transaction, Request<String> request)
    throws Exception {

  if (transaction.getSession().isNew()) {
    transaction.sendResponse("new");
  } else {
    transaction.sendResponse("old");
  }
}
 
Example 13
Source File: ReconnectionFromServerTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequest(final Transaction transaction, Request<String> request)
    throws Exception {

  log.debug("Receive request in server: " + request);

  if (session == null) {
    session = transaction.getSession();
  }

  if (session.isNew()) {
    transaction.sendResponse("new");
  } else {
    transaction.sendResponse("old");
  }

  log.debug("Response sent from server");

  executor.schedule(new Runnable() {
    @Override
    public void run() {
      try {
        log.debug("Request send from server");
        JsonElement result = session.sendRequest("hello");
        log.debug("Response received in server");
        log.debug("Result: " + result);
        s.release();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }, 500, TimeUnit.MILLISECONDS);
}
 
Example 14
Source File: MultipleSessionsTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequest(Transaction transaction, Request<String> request) throws Exception {

  if (demoBean == null) {
    throw new RuntimeException("Not autowired dependencies");
  }

  transaction.sendResponse(counter);
  counter++;
}
 
Example 15
Source File: JsonRpcClientLocalTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequest(Transaction transaction, Request<JsonObject> request)
    throws Exception {

  LOG.info("Request id:" + request.getId());
  LOG.info("Request method:" + request.getMethod());
  LOG.info("Request params:" + request.getParams());

  transaction.sendResponse(request.getParams());
}
 
Example 16
Source File: PingPongTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Override
public void handleRequest(final Transaction transaction, Request<String> request)
    throws Exception {

  transaction.sendResponse("OK");
}
 
Example 17
Source File: RomServerJsonRpcHandler.java    From kurento-java with Apache License 2.0 3 votes vote down vote up
private void handleCreateCommand(Transaction transaction, String type,
    JsonObject constructorParams) throws IOException {

  Object result = server.create(type, JsonUtils.fromJson(constructorParams, Props.class));

  transaction.sendResponse(result);
}
 
Example 18
Source File: LargePackageTest.java    From kurento-java with Apache License 2.0 3 votes vote down vote up
@Override
public void handleRequest(final Transaction transaction, Request<Integer> request)
    throws Exception {

  String largeString = newLargeString();

  System.out.println(largeString.getBytes().length);

  transaction.sendResponse(largeString);
}
 
Example 19
Source File: EchoJsonRpcHandler.java    From kurento-java with Apache License 2.0 3 votes vote down vote up
@Override
public void handleRequest(Transaction transaction, Request<JsonObject> 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());

}