Java Code Examples for org.kurento.jsonrpc.client.JsonRpcClient#connect()

The following examples show how to use org.kurento.jsonrpc.client.JsonRpcClient#connect() . 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: KurentoClient.java    From kurento-java with Apache License 2.0 6 votes vote down vote up
protected KurentoClient(JsonRpcClient client) {
  this.client = client;
  this.manager = new RomManager(new RomClientJsonRpcClient(client));
  client.setRequestTimeout(requesTimeout);
  client.setConnectionTimeout((int) connectionTimeout);
  if (client instanceof AbstractJsonRpcClientWebSocket) {
    ((AbstractJsonRpcClientWebSocket) client).enableHeartbeat(KEEPALIVE_TIME);
  }
  try {
    long start = System.currentTimeMillis();
    client.connect();
    long duration = System.currentTimeMillis() - start;

    if (duration > WARN_CONNECTION_TIME) {
      log.warn("Connected to KMS in {} millis (> {} millis)", duration, WARN_CONNECTION_TIME);
    }

  } catch (Exception e) {
    throw new KurentoException("Exception connecting to KMS", e);
  }
}
 
Example 2
Source File: CloseMessageTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void test() throws IOException, InterruptedException {

  JsonRpcClientWebSocket client = (JsonRpcClientWebSocket) createJsonRpcClient("/reconnection");
  client.setSendCloseMessage(true);

  Assert.assertEquals("new", client.sendRequest("sessiontest", String.class));
  Assert.assertEquals("old", client.sendRequest("sessiontest", String.class));
  Assert.assertEquals("old", client.sendRequest("sessiontest", String.class));

  String sessionId = client.getSession().getSessionId();

  client.close();

  JsonRpcClient client2 = createJsonRpcClient("/reconnection");
  client2.connect();
  client2.setSessionId(sessionId);

  Assert.assertEquals("new", client2.sendRequest("sessiontest", String.class));
  Assert.assertEquals("old", client2.sendRequest("sessiontest", String.class));

}