See: Description
Interface | Description |
---|---|
EventFamily |
Interface for Event Family.
|
EventListenersResolver |
Public access interface for events listener resolution request.
Use this module to find endpoints which are able to receive events by list of events' fully-qualified names. NOTE: Operations server will respond with list of endpoints which can receive ALL listed event types (FQNs). |
EventManager |
Interface for event management.
|
FetchEventListeners |
Listener interface for retrieving endpoints list
which supports requested event class FQNs
|
Class | Description |
---|---|
DefaultEventManager |
Default
EventManager implementation. |
EndpointAccessToken |
Represents endpoint access token which has to be passed for endpoint attachment.
|
EndpointKeyHash |
Represents endpoint key hash returned from OPS after it was successfully attached.
|
EventFamilyFactory |
Factory for accessing supported event families.
|
EndpointRegistrationManager
For the example, we have one event class family named "ExampleClassFamily":
[
{
"namespace": "org.kaa.example.events",
"name": "TestEvent",
"type": "record",
"fields": []
}
]
EventFamilyFactory factory = Kaa.getClient().getEventFamilyFactory();
ExampleClassFamily classFamily = factory.getExampleClassFamily();
classFamily.sendEventToAll(new TestEvent());
String target = "lZjEzq4E/D5aWjXYuG1N2sKYt/U="; // Target's public key hash.
classFamily.sendEvent(new TestEvent(), target);
TransactionId blockId = Kaa.getClient().getEventFamilyFactory().startEventsBlock();
Events block can contain events from different event class families.
TestEvent event1 = new TestEvent();
TestEvent event2 = new TestEvent();
// Sending event1 to a concrete target and broadcasting event2 to all endpoints.
String target = "lZjEzq4E/D5aWjXYuG1N2sKYt/U="; // Target's public key hash.
classFamily.addEventToBlock(blockId, event1, target);
classFamily.addEventToBlock(blockId, event2);
If events block is completed use next call to send events:
Kaa.getClient().getEventFamilyFactory().submitEventsBlock(blockId);
In order to remove events block (events will not be sent) use:
Kaa.getClient().getEventFamilyFactory().removeEventsBlock(blockId);
classFamily.addEventFamilyListener(new ExampleClassFamily.ExampleClassFamilyListener {
\@Override
public void onEvent(TestEvent event, String source) {
System.out.println("Received event TestEvent!");
}
});
Kaa.getClient().getEventListenersResolver().findEventListeners(Arrays.asList("org.kaa.example.events.TestEvent"), new FetchEventListeners() {
\@Override
public void onEventListenersReceived(List<String> eventListeners) {
// process response
}
\@Override
public void onRequestFailed() {
}
});
NOTE: Passing multiple events fqns means that recipient MUST support
receiving ALL mentioned events.
Copyright © 2015. All rights reserved.