Leosac  0.8.0
Open Source Access Control
Leosac::Module::WebSockAPI::WebSockAPIModule Class Reference

A module that provide a websocket interface to Leosac. More...

#include <WebSockAPI.hpp>

+ Inheritance diagram for Leosac::Module::WebSockAPI::WebSockAPIModule:
+ Collaboration diagram for Leosac::Module::WebSockAPI::WebSockAPIModule:

Public Member Functions

 WebSockAPIModule (zmqpp::context &ctx, zmqpp::socket *pipe, const boost::property_tree::ptree &cfg, CoreUtilsPtr utils)
 
 ~WebSockAPIModule ()=default
 
virtual void run () override
 This is the main loop of the module. More...
 
CoreUtilsPtr core_utils ()
 This module explicitly expose CoreUtils to other object in the module. More...
 
- Public Member Functions inherited from Leosac::Module::BaseModule
 BaseModule (zmqpp::context &ctx, zmqpp::socket *pipe, const boost::property_tree::ptree &cfg, CoreUtilsPtr utils)
 Constructor of BaseModule. More...
 
virtual ~BaseModule ()=default
 

Private Attributes

uint16_t port_
 Port to bind the websocket endpoint. More...
 
std::string interface_
 IP address of the interface to listen on. More...
 
std::unique_ptr< WSServerwssrv_
 Our websocket server object. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Leosac::Module::BaseModule
virtual void handle_pipe ()
 The base class register the pipe_ socket to its reactor_ so that this function is called when the pipe_ is available from reading. More...
 
virtual void handle_control ()
 Handle called when a message on the module's control socket arrives. More...
 
virtual void dump_additional_config (zmqpp::message *out) const
 Dump additional configuration (for example module specific config file). More...
 
void dump_config (ConfigManager::ConfigFormat fmt, zmqpp::message *out_msg) const
 Fills a message with the module's configuration information. More...
 
void config_check (const std::string &obj_name, Leosac::Hardware::DeviceClass type)
 An helper that checks configuration the existence of some objects. More...
 
void config_check (const std::string &obj_name)
 An helper that checks configuration the existence of some objects. More...
 
- Protected Attributes inherited from Leosac::Module::BaseModule
zmqpp::context & ctx_
 A reference to the ZeroMQ context in case you need it to create additional socket. More...
 
zmqpp::socket & pipe_
 A reference to the pair socket that link back to the module manager. More...
 
boost::property_tree::ptree config_
 The configuration tree passed to the start_module function. More...
 
CoreUtilsPtr utils_
 Pointer to the core utils, which gives access to scheduler and others. More...
 
bool is_running_
 Boolean indicating whether the main loop should run or not. More...
 
zmqpp::socket control_
 Control REP socket. More...
 
zmqpp::reactor reactor_
 The reactor object we poll() on in the main loop. More...
 
std::string name_
 

Detailed Description

A module that provide a websocket interface to Leosac.

The websocket API is designed to be exposed to the world. It can be used to implement various UI to Leosac.

The module also provide a key utility to other modules:

  • It can passthrough websocket traffic, effectively giving the ability to any module to expose a websocket API for itself.

This module registers the WebSockAPI::Service object. It can be used to register handler for specific message type.

Definition at line 46 of file WebSockAPI.hpp.

Constructor & Destructor Documentation

◆ WebSockAPIModule()

WebSockAPIModule::WebSockAPIModule ( zmqpp::context &  ctx,
zmqpp::socket *  pipe,
const boost::property_tree::ptree &  cfg,
CoreUtilsPtr  utils 
)

Definition at line 32 of file WebSockAPI.cpp.

◆ ~WebSockAPIModule()

Leosac::Module::WebSockAPI::WebSockAPIModule::~WebSockAPIModule ( )
default

Member Function Documentation

◆ core_utils()

CoreUtilsPtr WebSockAPIModule::core_utils ( )

This module explicitly expose CoreUtils to other object in the module.

Definition at line 60 of file WebSockAPI.cpp.

◆ run()

void WebSockAPIModule::run ( )
overridevirtual

This is the main loop of the module.

It should only exit when receiving signal::stop on its pipe_ socket. This is completely handled by this base class. In case you override this, make sure you watch the pipe_ socket.

Reimplemented from Leosac::Module::BaseModule.

Definition at line 46 of file WebSockAPI.cpp.

Member Data Documentation

◆ interface_

std::string Leosac::Module::WebSockAPI::WebSockAPIModule::interface_
private

IP address of the interface to listen on.

Definition at line 71 of file WebSockAPI.hpp.

◆ port_

uint16_t Leosac::Module::WebSockAPI::WebSockAPIModule::port_
private

Port to bind the websocket endpoint.

Definition at line 66 of file WebSockAPI.hpp.

◆ wssrv_

std::unique_ptr<WSServer> Leosac::Module::WebSockAPI::WebSockAPIModule::wssrv_
private

Our websocket server object.

Definition at line 76 of file WebSockAPI.hpp.


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