Crow  1.0
A C++ microframework for the web
crow::WebSocketRule Class Reference

A rule dealing with websockets. More...

Inheritance diagram for crow::WebSocketRule:
Collaboration diagram for crow::WebSocketRule:

Public Member Functions

 WebSocketRule (std::string rule)
 
void validate () override
 
void handle (request &, response &res, const routing_params &) override
 
void handle_upgrade (const request &req, response &, SocketAdaptor &&adaptor) override
 
template<typename Func >
self_tonopen (Func f)
 
template<typename Func >
self_tonmessage (Func f)
 
template<typename Func >
self_tonclose (Func f)
 
template<typename Func >
self_tonerror (Func f)
 
template<typename Func >
self_tonaccept (Func f)
 
std::unique_ptr< BaseRuleupgrade ()
 
uint32_t get_methods ()
 
template<typename F >
void foreach_method (F f)
 
const std::string & rule ()
 

Public Attributes

std::string custom_templates_base
 

Protected Attributes

std::function< void(crow::websocket::connection &)> open_handler_
 
std::function< void(crow::websocket::connection &, const std::string &, bool)> message_handler_
 
std::function< void(crow::websocket::connection &, const std::string &)> close_handler_
 
std::function< void(crow::websocket::connection &)> error_handler_
 
std::function< bool(const crow::request &)> accept_handler_
 
uint32_t methods_ {1 << static_cast<int>(HTTPMethod::Get)}
 
std::string rule_
 
std::string name_
 
std::unique_ptr< BaseRulerule_to_upgrade_
 

Private Types

using self_t = WebSocketRule
 

Detailed Description

A rule dealing with websockets.

Provides the interface for the user to put in the necessary handlers for a websocket to work.

Member Typedef Documentation

◆ self_t

Constructor & Destructor Documentation

◆ WebSocketRule()

crow::WebSocketRule::WebSocketRule ( std::string  rule)
inline

Member Function Documentation

◆ validate()

void crow::WebSocketRule::validate ( )
inlineoverridevirtual

Implements crow::BaseRule.

◆ handle()

void crow::WebSocketRule::handle ( request ,
response res,
const routing_params &   
)
inlineoverridevirtual

Implements crow::BaseRule.

Here is the call graph for this function:

◆ handle_upgrade()

void crow::WebSocketRule::handle_upgrade ( const request req,
response ,
SocketAdaptor &&  adaptor 
)
inlineoverridevirtual

Reimplemented from crow::BaseRule.

◆ onopen()

template<typename Func >
self_t& crow::WebSocketRule::onopen ( Func  f)
inline

◆ onmessage()

template<typename Func >
self_t& crow::WebSocketRule::onmessage ( Func  f)
inline

◆ onclose()

template<typename Func >
self_t& crow::WebSocketRule::onclose ( Func  f)
inline

◆ onerror()

template<typename Func >
self_t& crow::WebSocketRule::onerror ( Func  f)
inline

◆ onaccept()

template<typename Func >
self_t& crow::WebSocketRule::onaccept ( Func  f)
inline

◆ upgrade()

std::unique_ptr<BaseRule> crow::BaseRule::upgrade ( )
inlineinherited

◆ get_methods()

uint32_t crow::BaseRule::get_methods ( )
inlineinherited

◆ foreach_method()

template<typename F >
void crow::BaseRule::foreach_method ( f)
inlineinherited
Here is the caller graph for this function:

◆ rule()

const std::string& crow::BaseRule::rule ( )
inlineinherited

Member Data Documentation

◆ open_handler_

std::function<void(crow::websocket::connection&)> crow::WebSocketRule::open_handler_
protected

◆ message_handler_

std::function<void(crow::websocket::connection&, const std::string&, bool)> crow::WebSocketRule::message_handler_
protected

◆ close_handler_

std::function<void(crow::websocket::connection&, const std::string&)> crow::WebSocketRule::close_handler_
protected

◆ error_handler_

std::function<void(crow::websocket::connection&)> crow::WebSocketRule::error_handler_
protected

◆ accept_handler_

std::function<bool(const crow::request&)> crow::WebSocketRule::accept_handler_
protected

◆ custom_templates_base

std::string crow::BaseRule::custom_templates_base
inherited

◆ methods_

uint32_t crow::BaseRule::methods_ {1 << static_cast<int>(HTTPMethod::Get)}
protectedinherited

◆ rule_

std::string crow::BaseRule::rule_
protectedinherited

◆ name_

std::string crow::BaseRule::name_
protectedinherited

◆ rule_to_upgrade_

std::unique_ptr<BaseRule> crow::BaseRule::rule_to_upgrade_
protectedinherited

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