Class NetioSubscriber
Defined in File NetioSubscriber.hpp
Class Documentation
-
class NetioSubscriber
The subscriber class is responsible receiving data from publishers.
A subscriber contains a dedicated TCP/ASYNCMSG backend used to send subscription requests and receive acknowledgements to/from publishers.
It also contains a NetioReceiver which is used to receive the actual data from the publishers. The connection type of the receive is determined by the config passed to the constructor.
On data reception, the subscriber will call the on_data_cb callback with the received decoded data and/or the on_buffer_cb callback with the received buffer.
Public Functions
Constructor for subscriber.
- Parameters:
config – Configuration of the network backend and buffering
evloop – Pointer to event loop that runs netio operations
local_ep – Endpoint on which we listen for incoming data
-
NetioSubscriber(const NetioSubscriber&) = delete
-
NetioSubscriber(const NetioSubscriber&&) = delete
-
NetioSubscriber() = delete
-
NetioSubscriber &operator=(const NetioSubscriber&) = delete
-
NetioSubscriber &operator=(const NetioSubscriber&&) = delete
-
~NetioSubscriber()
Destructor for subscriber (unsubscribe all)
-
NetioStatus subscribe(uint64_t tag, const EndPointAddress &remote_ep, const ConnectionParametersRecv &conn_params)
Subscribe to data for a tag.
Opens connections if necessary. If this function returns NO_RESOURCES, the user should try again.
- Parameters:
tag – Tag for which data is required
ep – Endpoint from which data are to be subscribed
conn_params – Configuration for the opened receive endpoints
- Returns:
A NetioStatus code giving the status from the sending of the request to the endpoint (See NetioSender for details)
-
NetioStatus unsubscribe(uint64_t tag, const EndPointAddress &remote_ep)
Remove subscription for a tag from an endpoint.
Closes the subscription connection if no more subscriptions are active to that endpoint anymore. If this function returns NO_RESOURCES, the user should try again.
- Parameters:
tag – Tag for which data is to be unsubscribed
remote_ep – Endpoint from which data are to be unsubscribed
- Returns:
A NetioStatus code giving the status from the sending of the request to the endpoint (See NetioSender for details)
-
void set_on_subscription_cb(const CbSubscriptionConfirmed &cb)
Set a callback for when a subscription was successful.
This means, the acknowledgement was received from the publisher.
- Parameters:
cb – Callback function
-
void set_on_unsubscription_cb(const CbUnsubscriptionConfirmed &cb)
Set a callback for when a unsubscription was successful.
This means, the acknowledgement was received from the publisher.
- Parameters:
cb – Callback function
-
void set_on_data_cb(const CbMessageReceived &cb)
Set a callback function to be called when data are received.
This callback is the main purpose of this class. Invoked for each decoded message inside a buffer.
- Parameters:
cb – Callback function
-
void set_on_buffer_cb(const CbBufferReceived &cb)
Set a callback function to be called when data are received.
This callback is the main purpose of this class. Invoked with the entire buffer.
- Parameters:
cb – Callback function
-
void set_on_subscription_lost_cb(const CbSubscriptionLost &cb)
Set a callback for when an endpoint with active subscriptions has been closed.
Callback will be called with a set of uint64_t tags which were subscribed to on the endpoint that has closed.
- Parameters:
cb – Callback function