RKH
rkhfwk_pubsub.h File Reference

Specifies the publish-subscribe interface. More...

#include "rkhitl.h"
Include dependency graph for rkhfwk_pubsub.h:

Go to the source code of this file.

Functions

void rkh_pubsub_init (void)
 Encapsulates the initialization of publish-subscribe module. More...
 
void rkh_pubsub_subscribe (rui8_t channel, const RKH_SMA_T *ao)
 Adds an active object to the notification list of an event channel. Each subscription registers a client's interest in one event channel (topic). This module posts published events to the registered clients in order to forward events that were published to channel that match this subscription. More...
 
void rkh_pubsub_unsubscribe (rui8_t channel, const RKH_SMA_T *ao)
 Unsubscribes an active object from topic. More...
 
void rkh_pubsub_unsubscribeAll (const RKH_SMA_T *ao)
 Unsubscribes an active object from all topics. More...
 
rui8_t rkh_pubsub_publish (rui8_t channel, RKH_EVT_T *event, const void *const sender)
  More...
 

Detailed Description

Specifies the publish-subscribe interface.

This module addresses the specific issue of how to notify a set of interested active objects (clients) in a timely way that a value that they care about has changed, especially when the notification process is to be repeated for a relatively long period of time. It does this without requiring the data server to have any a priori knowledge about its clients. The basic solution offered by PubSub module is to have the clients "subscribe" to the server to be notified about the value in question according to the policy: "when the value changes", receiving a proper event carrying the value of interest. This means, for example, that sensor data can be easily shared to elements that may not even exist when the sensor proxies are written. Also, minimizes computational effort for notification of clients and across a communications bus and minimizes the bus bandwidth required for notification of the appropriate clients.

Definition in file rkhfwk_pubsub.h.

Function Documentation

◆ rkh_pubsub_init()

void rkh_pubsub_init ( void  )

Encapsulates the initialization of publish-subscribe module.

Note
It should be invoked before using any publish-subscribe method.

◆ rkh_pubsub_subscribe()

void rkh_pubsub_subscribe ( rui8_t  channel,
const RKH_SMA_T ao 
)

Adds an active object to the notification list of an event channel. Each subscription registers a client's interest in one event channel (topic). This module posts published events to the registered clients in order to forward events that were published to channel that match this subscription.

Parameters
[in]channelindicates the topic to which the active object (client) wants to subscribe.
[in]aopointer to previously created active object to subscribe.

◆ rkh_pubsub_unsubscribe()

void rkh_pubsub_unsubscribe ( rui8_t  channel,
const RKH_SMA_T ao 
)

Unsubscribes an active object from topic.

Parameters
[in]channelindicates the topic that the active object wishes to unsubscribe from.
[in]aopointer to previously created active object to unsubscribe.

◆ rkh_pubsub_unsubscribeAll()

void rkh_pubsub_unsubscribeAll ( const RKH_SMA_T ao)

Unsubscribes an active object from all topics.

Parameters
[in]aopointer to previously created active object to unsubscribe.

◆ rkh_pubsub_publish()

rui8_t rkh_pubsub_publish ( rui8_t  channel,
RKH_EVT_T event,
const void *const  sender 
)
Parameters
[in]channelidentifies the information channel to which event is published.
[in]eventpointer to event to publish
[in]senderpointer to the sender object. It is not necessarily a pointer to an active object. In fact, if rkh_pubsub_publish() is called from an interrupt or other context, it can create a unique object just to unambiguously identify the publisher of the event.
Returns
The number of found ready active objects.