# Crow: crow::WebSocketRule< App > Class Template Reference

crow::WebSocketRule< App > Class Template Reference

A rule dealing with websockets. More...

`#include <routing.h>`

Inheritance diagram for crow::WebSocketRule< App >:

## Public Member Functions

| WebSocketRule (std::string rule, App *app)
void | validate () override
void | handle (request &, response &res, const routing_params &) override
void | handle_upgrade (const request &req, response &, SocketAdaptor &&adaptor) override
void | handle_upgrade (const request &req, response &, SSLAdaptor &&adaptor) override
self_t & | max_payload (uint64_t max_payload)
| Override the global payload limit for this single WebSocket rule.
template<typename Func >
self_t & | onopen (Func f)
template<typename Func >
self_t & | onmessage (Func f)
template<typename Func >
self_t & | onclose (Func f)
template<typename Func >
self_t & | onerror (Func f)
template<typename Func >
self_t & | onaccept (Func f)
Public Member Functions inherited from crow::BaseRule
| BaseRule (std::string rule)
void | set_added ()
bool | is_added ()
std::unique_ptr< BaseRule > | upgrade ()
uint32_t | get_methods ()
template<typename F >
void | foreach_method (F f)
const std::string & | rule ()

## Protected Attributes

App * | app_
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 &, const std::string &)> | error_handler_
std::function< bool(const crow::request &, void **)> | accept_handler_
uint64_t | max_payload_
bool | max_payload_override_ = false
Protected Attributes inherited from crow::BaseRule
uint32_t | methods_ {1 << static_cast<int>(HTTPMethod::Get)}
std::string | rule_
std::string | name_
bool | added_ {false}
std::unique_ptr< BaseRule > | rule_to_upgrade_
detail::middleware_indices | mw_indices_

## Additional Inherited Members

Public Attributes inherited from crow::BaseRule
std::string | custom_templates_base

## Detailed Description

### template<typename App>
class crow::WebSocketRule< App >

A rule dealing with websockets.

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

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

- include/crow/routing.h