33 #include <boost/optional.hpp>    35 #include <type_traits>    36 #include <websocketpp/config/asio_no_tls.hpp>    37 #include <websocketpp/server.hpp>    38 #include <zmqpp/zmqpp.hpp>    71     using Server           = websocketpp::server<websocketpp::config::asio>;
    73                                       std::owner_less<websocketpp::connection_hdl>>;
    75     void run(
const std::string &interface, uint16_t port);
    96                                const std::string &name);
   145     void on_open(websocketpp::connection_hdl hdl);
   147     void on_close(websocketpp::connection_hdl hdl);
   166     void on_message(websocketpp::connection_hdl hdl, Server::message_ptr msg);
   237     std::map<std::string, json (APISession::*)(const json &)> 
handlers_;
   264     std::unique_ptr<boost::asio::io_service::work> 
work_;
 
ClientMessage parse_request(const json &in)
Create a ClientMessage object from a json request. 
 
CRUDResourceHandlerUPtr(*)(RequestContext) Factory
 
This is the header file for a generated source file, GitSHA1.cpp. 
 
bool has_handler(const std::string &name) const
Returns true if an handler named name already exists. 
 
void register_crud_handler(const std::string &resource_name, CRUDResourceHandler::Factory factory)
An internal helper function to register a CRUD resource handler. 
 
std::shared_ptr< IWSAPICall > IWSAPICallPtr
 
std::map< std::string, json(APISession::*)(const json &)> handlers_
This maps (string) command name to API method. 
 
boost::optional< ServerMessage > handle_request(APIPtr api_handle, const ClientMessage &msg, Audit::IAuditEntryPtr)
Handle a request. 
 
std::map< websocketpp::connection_hdl, APIPtr, std::owner_less< websocketpp::connection_hdl > > ConnectionAPIMap
 
void on_close(websocketpp::connection_hdl hdl)
 
void register_crud_handler_external(const std::string &resource_name, CRUDResourceHandler::Factory factory)
Register a CRUD handler from an external thread. 
 
std::shared_ptr< IAuditEntry > IAuditEntryPtr
 
void finalize_audit(const Audit::IWSAPICallPtr &audit, ServerMessage &msg)
Extract values from the msg and finalizes the audit object with them. 
 
DBServicePtr dbsrv_
Database service object. 
 
boost::optional< json > dispatch_request(APIPtr api_handle, const ClientMessage &in, Audit::IAuditEntryPtr)
Dispatch the request from a client, so that it is processed by the appropriate handler. 
 
APIAuth & auth()
Retrieve the authentication helper. 
 
void attempt_unregister_ws_service()
 
The implementation class that runs the websocket server. 
 
DBPtr db()
Retrieve database handle. 
 
std::shared_ptr< DBService > DBServicePtr
 
std::shared_ptr< User > UserPtr
 
CoreUtilsPtr core_utils()
Retrieve the CoreUtils pointer. 
 
WSServer(WebSockAPIModule &module, DBPtr database)
 
std::map< std::string, MethodHandler::Factory > individual_handlers_
 
websocketpp::server< websocketpp::config::asio > Server
 
std::map< std::string, CRUDResourceHandler::Factory > crud_handlers_
 
std::map< std::string, Service::WSHandler > asio_handlers_
Handlers registered through the WebSockAPI::Service object. 
 
void clear_user_sessions(Auth::UserPtr user, APIPtr exception)
Deauthenticate all the connections of user, except the exception APISession. 
 
void run(const std::string &interface, uint16_t port)
 
WebSockAPIModule & module_
A reference to the module. 
 
std::shared_ptr< APISession > APIPtr
 
A message sent by the server to a client. 
 
std::shared_ptr< CoreUtils > CoreUtilsPtr
 
A message sent by a client to Leosac. 
 
ConnectionAPIMap connection_session_
 
void start_shutdown()
Start the process of shutting down the server. 
 
void on_message(websocketpp::connection_hdl hdl, Server::message_ptr msg)
A websocket message has been received. 
 
DBServicePtr dbsrv()
Retrieve database service pointer. 
 
std::shared_ptr< odb::database > DBPtr
 
bool register_asio_handler(const Service::WSHandler &handler, const std::string &name)
This function block the calling thread until the WebSocket thread has processed the handler registrat...
 
std::unique_ptr< boost::asio::io_service::work > work_
Work used to keep the io_service alive while someone has a reference to (WS) Service object...
 
This class is responsible for providing an API to manage authentication for Websocket client...
 
void on_open(websocketpp::connection_hdl hdl)
 
void send_message(websocketpp::connection_hdl hdl, const ServerMessage &msg)
Send a message over a connection. 
 
A module that provide a websocket interface to Leosac. 
 
void unregister_handler(const std::string &name)
Remove an Asio based handler. 
 
std::function< boost::optional< json >(const RequestContext &)> WSHandler