Class jac::Router
A router that can route packets from multiple data links to to consumers on specific channels.
#include <router.h>
Classes
Type | Name |
---|---|
class | Handle A handle for receiving packets from a data link. |
Public Functions
Type | Name |
---|---|
Router () = default |
|
Router (const Router &) = delete |
|
Router (Router &&) = delete |
|
std::unique_ptr< Packet > | buildPacket (uint8_t channel, std::vector< int > links) Build a packet for a channel and data links. |
size_t | maxPacketSize (uint8_t channel, std::vector< int > links) Get the maximum packet size for a channel and data links. |
Router & | operator= (const Router &) = delete |
Router & | operator= (Router &&) = delete |
void | setGlobalCallback (std::function< void(int linkId, uint8_t channel, std::span< const uint8_t > data)> callback) Set global callback which is called whenever a packet is received on any channel and data link. |
void | subscribeChannel (uint8_t channel, Consumer & consumer) Subscribe a channel to a consumer. |
Handle | subscribeTx (int id, DataLinkTx & tx) Subscribe a data link transmitter to the router. |
Public Functions Documentation
function Router [1/3]
function Router [2/3]
function Router [3/3]
function buildPacket
Build a packet for a channel and data links.
inline std::unique_ptr< Packet > jac::Router::buildPacket (
uint8_t channel,
std::vector< int > links
)
Parameters:
channel
the channellinks
the data links
Returns:
The packet
function maxPacketSize
Get the maximum packet size for a channel and data links.
Parameters:
channel
the channellinks
the data links
Returns:
The maximum packet size
function operator=
function operator=
function setGlobalCallback
Set global callback which is called whenever a packet is received on any channel and data link.
inline void jac::Router::setGlobalCallback (
std::function< void(int linkId, uint8_t channel, std::span< const uint8_t > data)> callback
)
Parameters:
callback
the callback
function subscribeChannel
Subscribe a channel to a consumer.
Note:
All packets received on the channel will be passed to the consumer.
Parameters:
channel
the channelconsumer
the consumer
function subscribeTx
Subscribe a data link transmitter to the router.
Note:
This allows router to send packets to the data link id. Reciever should be then bound to the returned handle.
Parameters:
id
id of the data linktx
the transmitter
Returns:
The handle
The documentation for this class was generated from the following file src/jac/link/router.h