Diffusion C API  6.1.5
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Receiving data from topics.

Functions

 DEPRECATED (BUF_T *cbor_to_json(const char *cbor, size_t len))
 Convert binary (CBOR) data to a JSON string. More...
 
void fetch (SESSION_T *session, const FETCH_PARAMS_T params)
 Fetch state for a topic (or many topics). More...
 
TOPIC_HANDLER_T subscribe (SESSION_T *session, const SUBSCRIPTION_PARAMS_T params)
 Subscribe to topics. More...
 
void unsubscribe (SESSION_T *session, const UNSUBSCRIPTION_PARAMS_T params)
 Unsubscribe from one or more topics. More...
 

Detailed Description

Function Documentation

DEPRECATED ( BUF_T cbor_to_jsonconst char *cbor, size_t len)

Convert binary (CBOR) data to a JSON string.

Deprecated:
This function is deprecated from version 6.1 onwards, and may be removed.

This function is useful for converting data received on a JSON topic from CBOR representation to a JSON string suitable for passing to a 3rd party JSON parser.

Note that this is introducing an extra step (i.e., CBOR -> string -> JSON) and if possible, you should read the CBOR tokens and convert them directly to JSON representation using facilities provided by your JSON library.

Parameters
cborA pointer to memory containing CBOR-encoded data.
lenThe length of the CBOR-encoded data.
Returns
A pointer to a BUF_T containing a JSON string, or NULL on error.
void fetch ( SESSION_T session,
const FETCH_PARAMS_T  params 
)

Fetch state for a topic (or many topics).

Parameters
sessionThe session handle. If NULL, the function returns immediately.
paramsParameters and callback handlers to be invoked to process the results of the fetch() call.
TOPIC_HANDLER_T subscribe ( SESSION_T session,
const SUBSCRIPTION_PARAMS_T  params 
)

Subscribe to topics.

This function has the roles of subscribing to the topics specified by the selector and installing handlers for received TOPIC_MESSAGE_T messages which match that selector and also any other service messages related to subscription. These handlers are called before (and in addition to) any handlers installed using add_message_handler() for MESSAGE_TYPE_TOPIC_LOAD or MESSAGE_TYPE_DELTA messages.

If a topic handler was already registered for the supplied selector, it is replaced and the old handlers are returned.

Parameters
sessionThe session handle. If NULL, the function returns immediately.
paramsParameters describing the subscription request and callbacks handlers which may be invoked in response.
Returns
Previous topic handler if replacing, else NULL.
void unsubscribe ( SESSION_T session,
const UNSUBSCRIPTION_PARAMS_T  params 
)

Unsubscribe from one or more topics.

This function has the roles of subscribing to the topics specified by the selector and installing handlers for received TOPIC_MESSAGE_T messages which match that selector and also any other service messages related to unsubscription.

Parameters
sessionThe session handle. If NULL, this function returns immediately.
paramsParameters describing the unsubscription request and callback handlers which may be invoked in response.