HiveMindBridge
Public Member Functions | Private Member Functions | Private Attributes | List of all members
HiveMindBridgeImpl Class Reference

#include <HiveMindBridgeImpl.h>

Collaboration diagram for HiveMindBridgeImpl:
Collaboration graph

Public Member Functions

 HiveMindBridgeImpl (ITCPServer &tcpServer, IHiveMindHostSerializer &serializer, IHiveMindHostDeserializer &deserializer, IUserCallRequestHandler &userCallRequestManager, IHiveMindHostRequestHandler &hmRequestHandler, IUserCallbackMap &userCallbackMap, IMessageHandler &messageHandler, IThreadSafeQueue< MessageDTO > &inboundQueue, IThreadSafeQueue< OutboundRequestHandle > &outboundQueue, ILogger &logger, uint32_t keepAliveNbSpin)
 
 ~HiveMindBridgeImpl ()
 
void spin ()
 
void onConnect (std::function< void()> hook)
 
void onDisconnect (std::function< void()> hook)
 
bool onBytesReceived (std::function< void(uint8_t *bytes, uint64_t bytesLength)> callback)
 
bool registerCustomAction (std::string name, CallbackFunction callback, CallbackArgsManifest manifest)
 
bool registerCustomAction (std::string name, CallbackFunction callback)
 
bool queueAndSend (MessageDTO message)
 
bool sendBytes (uint32_t destinationId, const uint8_t *const payload, uint16_t payloadSize)
 
uint32_t getSwarmAgentId () const
 
bool sendNeighborUpdateRequest (uint16_t neighborId)
 
bool sendNeighborListUpdateRequest ()
 

Private Member Functions

void inboundThread ()
 
void outboundThread ()
 
bool isTCPClientConnected ()
 
void sendReturn (InboundRequestHandle &result)
 
bool greet ()
 

Private Attributes

ILogger & m_logger
 
ITCPServerm_tcpServer
 
IHiveMindHostDeserializer & m_deserializer
 
IHiveMindHostSerializer & m_serializer
 
IUserCallRequestHandlerm_userCallRequestHandler
 
IHiveMindHostRequestHandlerm_hmRequestHandler
 
IUserCallbackMapm_userCallbackMap
 
IMessageHandlerm_messageHandler
 
IThreadSafeQueue< MessageDTO > & m_inboundQueue
 
std::thread m_inboundThread
 
IThreadSafeQueue< OutboundRequestHandle > & m_outboundQueue
 
std::thread m_outboundThread
 
std::mutex m_mutex
 
std::deque< InboundRequestHandlem_inboundRequestsQueue
 
std::unordered_map< uint32_t, InboundResponseHandlem_inboundResponsesMap
 
uint32_t m_swarmAgentID = 0
 
const uint32_t m_keepAliveNbSpin
 
uint32_t m_keepAliveCounter = 0
 

Constructor & Destructor Documentation

◆ HiveMindBridgeImpl()

HiveMindBridgeImpl::HiveMindBridgeImpl ( ITCPServer tcpServer,
IHiveMindHostSerializer &  serializer,
IHiveMindHostDeserializer &  deserializer,
IUserCallRequestHandler userCallRequestManager,
IHiveMindHostRequestHandler hmRequestHandler,
IUserCallbackMap userCallbackMap,
IMessageHandler messageHandler,
IThreadSafeQueue< MessageDTO > &  inboundQueue,
IThreadSafeQueue< OutboundRequestHandle > &  outboundQueue,
ILogger &  logger,
uint32_t  keepAliveNbSpin 
)

Construct a HiveMind Bridge object by injecting already-initialised objects.

Parameters
tcpServerA TCPServer to be used
serializerA HiveMindHostSerializer to be used
deserializerA HiveMindHostDeserializer to be used
userCallRequestManagerA manager for the usercall request
hmRequestHandlerA request handler
userCallbackMapA map of the usercallback
messageHandlerA MessageHandler to be used
inboundQueueA ThreadSafeQueue to be used for inbound messages
outboundQueueA ThreadSafeQueue to be used for outbound request handles
loggerThe logger used in the bridge
keepAliveNbSpinNumber of call to spin before a greet is sent to keep the connection alive. Set to 0 to disable

◆ ~HiveMindBridgeImpl()

HiveMindBridgeImpl::~HiveMindBridgeImpl ( )
Here is the call graph for this function:

Member Function Documentation

◆ getSwarmAgentId()

uint32_t HiveMindBridgeImpl::getSwarmAgentId ( ) const
Here is the caller graph for this function:

◆ greet()

bool HiveMindBridgeImpl::greet ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ inboundThread()

void HiveMindBridgeImpl::inboundThread ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isTCPClientConnected()

bool HiveMindBridgeImpl::isTCPClientConnected ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ onBytesReceived()

bool HiveMindBridgeImpl::onBytesReceived ( std::function< void(uint8_t *bytes, uint64_t bytesLength)>  callback)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ onConnect()

void HiveMindBridgeImpl::onConnect ( std::function< void()>  hook)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ onDisconnect()

void HiveMindBridgeImpl::onDisconnect ( std::function< void()>  hook)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ outboundThread()

void HiveMindBridgeImpl::outboundThread ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ queueAndSend()

bool HiveMindBridgeImpl::queueAndSend ( MessageDTO  message)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerCustomAction() [1/2]

bool HiveMindBridgeImpl::registerCustomAction ( std::string  name,
CallbackFunction  callback 
)
Here is the call graph for this function:

◆ registerCustomAction() [2/2]

bool HiveMindBridgeImpl::registerCustomAction ( std::string  name,
CallbackFunction  callback,
CallbackArgsManifest  manifest 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendBytes()

bool HiveMindBridgeImpl::sendBytes ( uint32_t  destinationId,
const uint8_t *const  payload,
uint16_t  payloadSize 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendNeighborListUpdateRequest()

bool HiveMindBridgeImpl::sendNeighborListUpdateRequest ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendNeighborUpdateRequest()

bool HiveMindBridgeImpl::sendNeighborUpdateRequest ( uint16_t  neighborId)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sendReturn()

void HiveMindBridgeImpl::sendReturn ( InboundRequestHandle result)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ spin()

void HiveMindBridgeImpl::spin ( )
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_deserializer

IHiveMindHostDeserializer& HiveMindBridgeImpl::m_deserializer
private

◆ m_hmRequestHandler

IHiveMindHostRequestHandler& HiveMindBridgeImpl::m_hmRequestHandler
private

◆ m_inboundQueue

IThreadSafeQueue<MessageDTO>& HiveMindBridgeImpl::m_inboundQueue
private

◆ m_inboundRequestsQueue

std::deque<InboundRequestHandle> HiveMindBridgeImpl::m_inboundRequestsQueue
private

◆ m_inboundResponsesMap

std::unordered_map<uint32_t, InboundResponseHandle> HiveMindBridgeImpl::m_inboundResponsesMap
private

◆ m_inboundThread

std::thread HiveMindBridgeImpl::m_inboundThread
private

◆ m_keepAliveCounter

uint32_t HiveMindBridgeImpl::m_keepAliveCounter = 0
private

◆ m_keepAliveNbSpin

const uint32_t HiveMindBridgeImpl::m_keepAliveNbSpin
private

◆ m_logger

ILogger& HiveMindBridgeImpl::m_logger
private

◆ m_messageHandler

IMessageHandler& HiveMindBridgeImpl::m_messageHandler
private

◆ m_mutex

std::mutex HiveMindBridgeImpl::m_mutex
private

◆ m_outboundQueue

IThreadSafeQueue<OutboundRequestHandle>& HiveMindBridgeImpl::m_outboundQueue
private

◆ m_outboundThread

std::thread HiveMindBridgeImpl::m_outboundThread
private

◆ m_serializer

IHiveMindHostSerializer& HiveMindBridgeImpl::m_serializer
private

◆ m_swarmAgentID

uint32_t HiveMindBridgeImpl::m_swarmAgentID = 0
private

◆ m_tcpServer

ITCPServer& HiveMindBridgeImpl::m_tcpServer
private

◆ m_userCallbackMap

IUserCallbackMap& HiveMindBridgeImpl::m_userCallbackMap
private

◆ m_userCallRequestHandler

IUserCallRequestHandler& HiveMindBridgeImpl::m_userCallRequestHandler
private

The documentation for this class was generated from the following files: