client-cpp  0.7.0
Event subsystem

Endpoint is able to send or receive events when it is attached to user. See User registration.

Auto-generated headers based on selected event class family schemas can be found in kaa/event/gen/.

Event classes definitions are separated into specific namespace for each event class family. Name of this namespace is defined as:


For the example, we have one event class family named "ExampleClassFamily":

"namespace": "",
"name": "TestEvent",
"type": "record",
"fields": []

Including header for ExampleClassFamily:

#include <kaa/event/gen/ExampleClassFamily.hpp>

Getting ExampleClassFamily instance:

using namespace kaa;
ExampleClassFamily &classFamily = Kaa::getKaaClient().getEventFamilyFactory().getExampleClassFamily();

Sending an event

Sending event to all available recipients:

nsExampleClassFamily::TestEvent event;


nsExampleClassFamily::TestEvent event;

Sending event to a concrete target:

std::string target = "lZjEzq4E/D5aWjXYuG1N2sKYt/U="; // Target's public key hash.
nsExampleClassFamily::TestEvent event;
classFamily.sendEvent(event, target);

Sending bulk of events.
Event blocks in sdk are identified by TransactionId key.

Create new empty events block:

TransactionIdPtr blockId = Kaa::getKaaClient().getEventFamilyFactory().startEventsBlock();

Events block can contain events from different event class families.
Add events to a block:

nsExampleClassFamily::TestEvent event1, event2;
// Sending event1 to a concrete target and broadcasting event2 to all endpoints.
std::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:


In order to remove events block (events will not be sent) use:


Receiving an event

Define event listener:

class ExampleEventsListener : public ExampleClassFamily::ExampleClassFamilyListener {
void onEvent(const nsExampleClassFamily::TestEvent &event, const std::string & source = "") {
std::cout << "Received event!" << std::endl;

Register event listener:

ExampleClassFamily::ExampleClassFamilyListener * listener = new ExampleEventsListener();

Searching for event recipients

class EventRecipientsResolveListener : public IFetchEventListeners {
void onEventListenersReceived(const std::vector<std::string >& eventListeners) {
for (const auto &target : eventListeners) {
std::cout << "Recipient key hash = " << target << std::endl;
void onRequestFailed() {
std::cout << "Failed to find recipients of event" << std::endl;
IFetchEventListeners *listener = new EventRecipientsResolveListener();
std::list<std::string > fqns = { "" };
Kaa::getKaaClient().getEventListenersResolver().findEventListeners(fqns, listener);

NOTE: Passing multiple events fqns means that recipient MUST support receiving ALL mentioned events.


User registration