Leosac
0.8.0
Open Source Access Control
|
A service object provided by the Websocket module. More...
#include <Service.hpp>
Public Types | |
using | WSHandler = std::function< boost::optional< json >(const RequestContext &)> |
Public Member Functions | |
Service (WSServer &server) | |
template<typename HandlerT > | |
bool | register_asio_handler (HandlerT &&handler, const std::string &type, boost::asio::io_service &io) |
Register an handler that will be invoked by the io_service io . More... | |
template<typename HandlerT > | |
bool | register_handler (HandlerT &&handler, const std::string &type) |
Register a handler for a websocket message. More... | |
void | register_crud_handler (const std::string &resource_name, CRUDResourceHandler::Factory factory) |
void | unregister_handler (const std::string &name) |
Remove an handler by name. More... | |
template<typename HandlerT > | |
bool | register_asio_handler_permission (HandlerT &&handler, const std::string &type, ActionActionParam permission, boost::asio::io_service &io) |
template<typename HandlerT > | |
bool | register_asio_handler_permission (HandlerT &&handler, const std::string &type, SecurityContext::Action permission, boost::asio::io_service &io) |
Private Member Functions | |
bool | register_typed_handler (const WSHandler &handler, const std::string &type) |
Register an handler that is ready to be invoked in the websocket thread. More... | |
Private Attributes | |
WSServer & | server_ |
A service object provided by the Websocket module.
Definition at line 45 of file Service.hpp.
using Leosac::Module::WebSockAPI::Service::WSHandler = std::function<boost::optional<json>(const RequestContext &)> |
Definition at line 53 of file Service.hpp.
|
inline |
Definition at line 48 of file Service.hpp.
|
inline |
Register an handler that will be invoked by the io_service io
.
Definition at line 62 of file Service.hpp.
|
inline |
Definition at line 112 of file Service.hpp.
|
inline |
Definition at line 126 of file Service.hpp.
void Leosac::Module::WebSockAPI::Service::register_crud_handler | ( | const std::string & | resource_name, |
CRUDResourceHandler::Factory | factory | ||
) |
Definition at line 41 of file Service.cpp.
|
inline |
Register a handler for a websocket message.
The handler will be invoked as-is in the websocket thread.
Definition at line 88 of file Service.hpp.
|
private |
Register an handler that is ready to be invoked in the websocket thread.
Definition at line 30 of file Service.cpp.
void Leosac::Module::WebSockAPI::Service::unregister_handler | ( | const std::string & | name | ) |
Remove an handler by name.
This should be called by module that register handlers before the module is destroyed in order to avoid a potential crash / race condition.
If you still have a registered asio-handler when the module goes out of scope, the websocket module will attempt to post()
to a dangling io_service, causing a crash.
Definition at line 36 of file Service.cpp.
|
private |
Definition at line 143 of file Service.hpp.