Leosac  0.8.0
Open Source Access Control
Leosac::Module::TCPNotifier::NotifierInstance Class Reference

This is an instance of the Notifier. More...

#include <NotifierInstance.hpp>

+ Collaboration diagram for Leosac::Module::TCPNotifier::NotifierInstance:

Classes

struct  TargetInfo
 Some information for each tcp server target. More...
 

Public Member Functions

 NotifierInstance (zmqpp::context &ctx, zmqpp::reactor &reactor, std::vector< std::string > auth_sources, std::vector< std::string > connect_to, std::vector< std::string > bind_to, ProtocolHandlerUPtr protocol_handler)
 Create a new notifier instance. More...
 
 ~NotifierInstance ()=default
 
 NotifierInstance (const NotifierInstance &)=delete
 
NotifierInstanceoperator= (const NotifierInstance &)=delete
 
 NotifierInstance (NotifierInstance &&o)=delete
 
NotifierInstanceoperator= (NotifierInstance &&o)=delete
 

Private Member Functions

void handle_credential (Cred::RFIDCard &card)
 Notify the peers of the card credential. More...
 
void handle_one (zmqpp::message &msg)
 
void handle_msg_bus ()
 
void handle_tcp_msg ()
 Some event on our ZMQ Stream socket. More...
 
void configure_tcp_socket (const std::vector< std::string > &endpoints)
 
TargetInfofind_target (const std::string &routing_id)
 Attempt to find a target from its routing_id. More...
 

Private Attributes

zmqpp::socket bus_sub_
 Read internal message bus. More...
 
zmqpp::socket tcp_
 Stream socket used to connect to remote client we want to notify. More...
 
std::list< TargetInfotargets_
 
ProtocolHandlerUPtr protocol_
 
bool act_as_server_
 Are we a server or a client ? More...
 

Detailed Description

This is an instance of the Notifier.

The module can have many NotifierInstance running concurrently.

Multiple instance are useful because they let the module act as server and/or client and talk to various peer using different protocols.

A instance is qualified by its status (server or client) and the protocol it speaks.

Note
Implementation note about peer management. When acting as a server, we remove a disconnected client from our targets_ (list of peer), and we create a new target when a client connects. When acting as a client, we always keep the list of server we connect to, and manage the state (connected or not).

Definition at line 58 of file NotifierInstance.hpp.

Constructor & Destructor Documentation

◆ NotifierInstance() [1/3]

NotifierInstance::NotifierInstance ( zmqpp::context &  ctx,
zmqpp::reactor &  reactor,
std::vector< std::string >  auth_sources,
std::vector< std::string >  connect_to,
std::vector< std::string >  bind_to,
ProtocolHandlerUPtr  protocol_handler 
)

Create a new notifier instance.

The context and the reactor are provided by the TcpNotifier module. The NotifierInstance shall register its socket to the reactor.

Warning
The Notifier can either bind or connect but not both at the same time.
Parameters
ctxThe ZeroMQ context.
reactorThe reactor of the parent module. We use this to register callback on socket.
auth_sourceThe list of authentication source to listen to.

Definition at line 31 of file NotifierInstance.cpp.

◆ ~NotifierInstance()

Leosac::Module::TCPNotifier::NotifierInstance::~NotifierInstance ( )
default

◆ NotifierInstance() [2/3]

Leosac::Module::TCPNotifier::NotifierInstance::NotifierInstance ( const NotifierInstance )
delete

◆ NotifierInstance() [3/3]

Leosac::Module::TCPNotifier::NotifierInstance::NotifierInstance ( NotifierInstance &&  o)
delete

Member Function Documentation

◆ configure_tcp_socket()

void NotifierInstance::configure_tcp_socket ( const std::vector< std::string > &  endpoints)
private

Definition at line 182 of file NotifierInstance.cpp.

◆ find_target()

NotifierInstance::TargetInfo * NotifierInstance::find_target ( const std::string &  routing_id)
private

Attempt to find a target from its routing_id.

Returns nullptr if the target cannot be found.

Definition at line 144 of file NotifierInstance.cpp.

◆ handle_credential()

void NotifierInstance::handle_credential ( Cred::RFIDCard card)
private

Notify the peers of the card credential.

Definition at line 58 of file NotifierInstance.cpp.

◆ handle_msg_bus()

void NotifierInstance::handle_msg_bus ( )
private

Definition at line 155 of file NotifierInstance.cpp.

◆ handle_one()

void NotifierInstance::handle_one ( zmqpp::message &  msg)
private

Definition at line 86 of file NotifierInstance.cpp.

◆ handle_tcp_msg()

void NotifierInstance::handle_tcp_msg ( )
private

Some event on our ZMQ Stream socket.

Definition at line 133 of file NotifierInstance.cpp.

◆ operator=() [1/2]

NotifierInstance& Leosac::Module::TCPNotifier::NotifierInstance::operator= ( const NotifierInstance )
delete

◆ operator=() [2/2]

NotifierInstance& Leosac::Module::TCPNotifier::NotifierInstance::operator= ( NotifierInstance &&  o)
delete

Member Data Documentation

◆ act_as_server_

bool Leosac::Module::TCPNotifier::NotifierInstance::act_as_server_
private

Are we a server or a client ?

Definition at line 151 of file NotifierInstance.hpp.

◆ bus_sub_

zmqpp::socket Leosac::Module::TCPNotifier::NotifierInstance::bus_sub_
private

Read internal message bus.

Definition at line 136 of file NotifierInstance.hpp.

◆ protocol_

ProtocolHandlerUPtr Leosac::Module::TCPNotifier::NotifierInstance::protocol_
private

Definition at line 146 of file NotifierInstance.hpp.

◆ targets_

std::list<TargetInfo> Leosac::Module::TCPNotifier::NotifierInstance::targets_
private

Definition at line 144 of file NotifierInstance.hpp.

◆ tcp_

zmqpp::socket Leosac::Module::TCPNotifier::NotifierInstance::tcp_
private

Stream socket used to connect to remote client we want to notify.

Definition at line 142 of file NotifierInstance.hpp.


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