DataSource for C SDK
8.0.4.341990-53978ef8
|
Interface that must be implemented in order to receive subscirption request and subscription discard events for DataSource subjects from connected DataSource peers. the implementation sends data to connected peers in response to subscription requests. More...
Data Fields | |
void(* | receive_discard )(void *context, int peer, const char *subject) |
Callback that informs a ds5_dataprovider_t that the subscription to a subject has been discarded and the DataSource application should stop sending data for this subject to the peer(s). More... | |
void(* | receive_request )(void *context, int peer, const char *subject) |
Callback that informs a ds5_dataprovider_t that a new subscription request has been received and it should start sending data. More... | |
Interface that must be implemented in order to receive subscirption request and subscription discard events for DataSource subjects from connected DataSource peers. the implementation sends data to connected peers in response to subscription requests.
You must implement both memebrs of this interface for your DataSource application to work correctly.
void(* ds5_dataprovider_t::receive_discard) (void *context, int peer, const char *subject) |
Callback that informs a ds5_dataprovider_t that the subscription to a subject has been discarded and the DataSource application should stop sending data for this subject to the peer(s).
context | - Application specific callback context as supplied to ds_create_active_publisher() or other function that return a ds5_publisher_t reference. |
peer | - The peer that is discarding the subject. This is supplied for informational purposes only. |
subject | - The subject that is being discarded. |
The implementation of this function depends on the type of ds5_publisher_t that is associated with this instance of ds5_dataprovider _t. If the ds5_publisher_t was created by calling ds5_create_compatibility_publisher(), receive_discard() is called once for each peer that discards the subject. This means that the DataSource application must keep track of the numbers of subscription requests and discards relating to each subject, so that it knows when to stop sending updates. It must only stop publishing data for a subject when there are no more peers subscribed to that subject.
If the ds5_publisher was created by calling ds5_create_active_publisher(), receive_discard() is only called once for a particular subject when the last peer has discarded that subject. The DataSource application must then stop publishing data for the subject. In this case the ds5_publisher does not have to count the numbers of subscription requests and discards, as the DataSource library handles this on behalf of the application.
void(* ds5_dataprovider_t::receive_request) (void *context, int peer, const char *subject) |
Callback that informs a ds5_dataprovider_t that a new subscription request has been received and it should start sending data.
context | - Application specific callback context as supplied to ds_create_active_publisher() or other function that return a ds5_publisher_t reference. |
peer | - The peer that is requesting the object. This is supplied for informational purposes only. |
subject | - The subject that is being requested. |
The normal way of implementing this function is to send an initial image of the requested subject back to the requesting peer. This is done by calling ds5_publish_response(), supplying the reference to ds5_publisher_t that was returned in a previous call to ds_create_active_publisher() or other function that returns such a reference.
If the ds5_publisher_t was created by calling ds5_create_compatibility_publisher(), receive_request() must keep track of the numbers of subscription requests relating to each subject, so that receive_discard() knows when to stop sending updates for a particular subject