.create();
}
@Test
public void receive_events() throws Exception {
GenesysClient client = new GenesysClient.Setup()
.serverUri(TestParams.SERVER_URI)
.credentials(TestParams.USERNAME, TestParams.PASSWORD)
.create();
// Optional: do a dummy request in order to get a session cookie
client.createRequest("GET", "/api/v2/diagnostics/version").execute();
GenesysEventReceiver eventReceiver = client.setupEventReceiver()
.eventExecutor(eventExecutor)
.create();
eventReceiver.open();
EventSubscription subscription = eventReceiver.subscribeAll(new GenesysEventListener() {
@Override public void eventReceived(GenesysEvent event) {
System.err.println(
"Handling event received from channel " + event.getChannel()
+ " in thread " + Thread.currentThread().getName()
+ " with content " + event.getContent());
}
});
client.createRequest("POST", "/api/v2/me")
.operationName("Ready")
.execute();
Thread.sleep(1000);
client.createRequest("POST", "/api/v2/me")
.operationName("NotReady")
.execute();
Thread.sleep(1000);