Skip to main content

Intrinsic pubsub

Intrinsic pubsub allows services and skills to exchange data by publishing and subscribing to topics. In the example below, we share an image across a skill and then receive it in a service.

// In the skill
#include "intrinsic/platform/pubsub/pubsub.h"

Image img;
PubSub pubsub; // Always keep the reference of Pubsub alive
INTR_ASSIGN_OR_RETURN(auto publisher,
pubsub->CreatePublisher("/skill1/analysis", TopicConfig()));
INTR_RETURN_IF_ERROR(publisher.Publish("/skill1/analysis", img));
// In the service
#include "intrinsic/platform/pubsub/pubsub.h"

Image img;
PubSub pubsub; // Always keep the reference of Pubsub alive
INTR_ASSIGN_OR_RETURN(
auto sub,
pubsub.CreateSubscription<Image>("/skill1/analysis",
[](const Image& img) {
// Here we process the received message.
},
[](absl::string_view packet, absl::Status error) {
// Here we handle receiving of an invalid message (Unimplemented).
});