Class FelixClientThreadInterface
Defined in File felix_client_thread_interface.hpp
Nested Relationships
Nested Types
Inheritance Relationships
Derived Type
public FelixClientThreadExtension(Class FelixClientThreadExtension)
Class Documentation
-
class FelixClientThreadInterface
Felix-client-thread interface class.
Note
Use it as a virtual class.
Subclassed by FelixClientThreadExtension
Public Types
-
typedef std::function<void(uint64_t fid, const uint8_t *data, size_t size, uint8_t status)> OnDataCallback
Data callback executed by the event loop (network reactor) thread.
- Attention
Blocking in this function blocks the eventloop, return as soon as possible.
- Param fid:
The fid (e-link identifier) from which the message originates
- Param data:
Pointer to data message
- Param size:
Size in bytes of the received message
- Param status:
One-byte field used to report errors in the message, see felix_client_status.h
-
typedef std::function<void()> OnInitCallback
Callback executed by event loop thread at start.
-
typedef std::function<void(uint64_t fid)> OnConnectCallback
Callback reporting that a connection has been established.
- Param fid:
The fid for which the connection is up.
-
typedef std::function<void(uint64_t fid)> OnDisconnectCallback
Callback reporting that a connection has been closed.
- Param fid:
The fid for which the connection is down.
-
typedef std::function<void()> UserFunction
User function to be passed to exec() for execution in the event loop.
-
typedef std::function<void()> OnUserTimerCallback
User timer function to be passed to callback_on_user_timer() for execution in the event loop.
-
typedef std::map<std::string, std::string> Properties
Data structure to hold configuration parameters defined in felix_client_properties header.
Public Functions
-
inline virtual ~FelixClientThreadInterface()
-
virtual void send_data(uint64_t fid, const uint8_t *data, size_t size, bool flush) = 0
Function to send a message to a remote fid.
This function takes care of establishing a connection to the remote endpoint if not already available. The send request is passed to the eventloop thread. The caller thread is blocked until the send operation is completed.
- Parameters:
fid – The fid, typically published by felix-toflx, to which the message is addressed to.
data – Pointer to message
size – Size of message
flush – For buffered mode, indicates if the buffer shall be sent right away.
- Throws:
FelixClientException – if the subscription fails.
-
virtual void subscribe(uint64_t fid) = 0
Subscribe to a given fid.
The remote endpoint is identified from felix-bus and a connection is established if not already present. The creation of sockets and network buffers is performed in the event loop thread. This function blocks the caller thread until an attempt to establish the connection has started or the subscription message is sent to the remote endpoint.
If a timeout is specified using the FELIX_CLIENT_TIMEOUT property, the function blocks until the subscription succeds or the timeout expires. A successful subscription will be either way acknowledge by the OnConnectCallback callback. A subscription is considered successful if the request was received by the remote endpoint.
- Parameters:
fid – The fid to subscribe to.
- Throws:
FelixClientException – if the send operation fails.
-
virtual void unsubscribe(uint64_t fid) = 0
Unsubscribe from a given fid.
Similar to subscribe(), it blocks until the unsubscribe request is sent to the remote endpoint. Since this is an asynchronous operation, it is not guaranteed that no data will arrive for this FID after the unsubscribe.
Note
If the application unsubscribed from all fids it is subscribe to, the remote endpoint will close the connection.
- Parameters:
fid – The fid to unsubscribe from.
- Throws:
FelixClientException – if the unsubscription fails.
-
virtual void exec(const UserFunction &user_function) = 0
Execute a function in the eventloop thread.
This function allows to execute a user function in the event loop thread.
- Parameters:
user_function – function pointer to user function.
-
struct Config
Data structure that includes both configuration parameters and pointers to callbacks.
Public Members
-
OnDataCallback on_data_callback
-
OnInitCallback on_init_callback
-
OnConnectCallback on_connect_callback
-
OnDisconnectCallback on_disconnect_callback
-
Properties property
-
OnDataCallback on_data_callback
-
typedef std::function<void(uint64_t fid, const uint8_t *data, size_t size, uint8_t status)> OnDataCallback