org.kurento.client.KurentoConnectionListener Java Examples

The following examples show how to use org.kurento.client.KurentoConnectionListener. 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: ExtraKmsFakeUsers.java    From kurento-room with Apache License 2.0 6 votes vote down vote up
protected synchronized KurentoClient getTestExtraFakeKurento() {
  if (testExtraFakeKurento == null) {
    testExtraFakeKurento = KurentoClient.create(testExtraFakeKmsWsUri,
        new KurentoConnectionListener() {
      @Override
      public void connected() {
      }

      @Override
      public void connectionFailed() {
      }

      @Override
      public void disconnected() {
        testExtraFakeKurento = null;
      }

      @Override
      public void reconnected(boolean sameServer) {
      }
    });
  }

  return testExtraFakeKurento;
}
 
Example #2
Source File: BaseMockedTest.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() {
	MockitoAnnotations.initMocks(this);
	mockStatic(KurentoClient.class);
	mockStatic(WebSocketHelper.class);
	doReturn(kServerManager).when(client).getServerManager();
	when(KurentoClient.create(nullable(String.class), any(KurentoConnectionListener.class))).thenReturn(client);
	doReturn(new TransactionImpl(romManager)).when(client).beginTransaction();
	handler.init();
}
 
Example #3
Source File: KurentoClientKmsConnectionTest.java    From kurento-java with Apache License 2.0 5 votes vote down vote up
@Test
public void errorSendingClosedKmsTest() throws Exception {

  String kmsUrl = kms.getWsUri();

  KurentoClient kurento = KurentoClient.create(kmsUrl, new KurentoConnectionListener() {

    @Override
    public void reconnected(boolean sameServer) {
    }

    @Override
    public void disconnected() {
      log.debug("Disconnected");
    }

    @Override
    public void connectionFailed() {
    }

    @Override
    public void connected() {
    }
  });

  kurento.createMediaPipeline();

  kms.stopKms();

  try {
    kurento.createMediaPipeline();
    fail("KurentoException should be thrown");
  } catch (KurentoException e) {
    assertThat(e.getMessage(), containsString("Exception connecting to WebSocket"));
  }
}
 
Example #4
Source File: ConnectionListenerTest.java    From kurento-java with Apache License 2.0 4 votes vote down vote up
@Test
public void disconnectionEventTest() throws InterruptedException, IOException {

  final CountDownLatch disconnectedLatch = new CountDownLatch(1);

  String kmsUrl = kms.getWsUri();

  log.debug("Connecting to KMS in " + kmsUrl);

  KurentoClient kurentoClient = KurentoClient.create(kmsUrl, new KurentoConnectionListener() {

    @Override
    public void disconnected() {
      log.debug("disconnected from KMS");
      disconnectedLatch.countDown();
    }

    @Override
    public void connectionFailed() {

    }

    @Override
    public void connected() {

    }

    @Override
    public void reconnected(boolean sameServer) {

    }
  });

  MediaPipeline pipeline = kurentoClient.createMediaPipeline();

  PlayerEndpoint player =
      new PlayerEndpoint.Builder(pipeline, "http://" + getTestFilesHttpPath()
          + "/video/format/small.webm").build();

  HttpPostEndpoint httpEndpoint = new HttpPostEndpoint.Builder(pipeline).build();

  player.connect(httpEndpoint);

  try {
    kms.stopKms();
  } catch (Exception e) {
    fail("Exception thrown when destroying kms. " + e);
  }

  log.debug("Waiting for disconnection event");
  if (!disconnectedLatch.await(60, TimeUnit.SECONDS)) {
    fail("Event disconnected should be thrown when kcs is destroyed");
  }
  log.debug("Disconnection event received");
}