# Crow: crow::WebSocketRule Class Reference

crow::WebSocketRule Class Reference

A rule dealing with websockets. More...

`#include <routing.h>`

Inheritance diagram for crow::WebSocketRule:

## Public Member Functions

| WebSocketRule (std::string rule)
void | validate () override
void | handle (const request &, response &res, const routing_params &) override
void | handle_upgrade (const request &req, response &, SocketAdaptor &&adaptor) override
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)
virtual void | validate ()=0
std::unique_ptr< BaseRule > | upgrade ()
virtual void | handle (const request &, response &, const routing_params &)=0
virtual void | handle_upgrade (const request &, response &res, SocketAdaptor &&)
uint32_t | get_methods ()
template<typename F >
void | foreach_method (F f)
const std::string & | rule ()

## 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_
Protected Attributes inherited from crow::BaseRule
uint32_t | methods_ {1<<static_cast<int>(HTTPMethod::Get)}
std::string | rule_
std::string | name_
std::unique_ptr< BaseRule > | rule_to_upgrade_

## 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 Function Documentation

## handle()

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

inlineoverridevirtual

Implements crow::BaseRule.

## handle_upgrade()

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

inlineoverridevirtual

Reimplemented from crow::BaseRule.

## validate()

void crow::WebSocketRule::validate | ( |  | ) |

inlineoverridevirtual

Implements crow::BaseRule.

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

- /home/farook/cppsrv/crow-0.3-fordoc/include/crow/routing.h