ESP32 HTTPS Server

Public Member Functions | Static Public Attributes | List of all members
httpsserver::WebsocketHandler Class Reference

## Public Member Functions
virtual void | onClose ()
| The default onClose handler. If no over-riding handler is provided for the "close" event, this method is called.
virtual void | onMessage (WebsocketInputStreambuf *pWebsocketInputStreambuf)
| The default onData handler. If no over-riding handler is provided for the "message" event, this method is called. A particularly useful pattern for using onMessage is: std::stringstream buffer; buffer << pWebSocketInputRecordStreambuf; This will read the whole message into the string stream.
virtual void | onError (std::string error)
| The default onError handler. If no over-riding handler is provided for the "error" event, this method is called.
void | close (uint16_t status=CLOSE_NORMAL_CLOSURE, std::string message="")
| Close the Web socket. More...
void | send (std::string data, uint8_t sendType=SEND_TYPE_BINARY)
| Send data down the web socket See the WebSocket spec (RFC6455) section "6.1 Sending Data". We build a WebSocket frame, send the frame followed by the data. More...
void | send (uint8_t *data, uint16_t length, uint8_t sendType=SEND_TYPE_BINARY)
| Send data down the web socket See the WebSocket spec (RFC6455) section "6.1 Sending Data". We build a WebSocket frame, send the frame followed by the data. More...
bool | closed ()
void | loop ()
void | initialize (ConnectionContext *con)

## Static Public Attributes
static const int | OPCODE_CONTINUE = 0x00
static const int | OPCODE_TEXT = 0x01
static const int | OPCODE_BINARY = 0x02
static const int | OPCODE_CLOSE = 0x08
static const int | OPCODE_PING = 0x09
static const int | OPCODE_PONG = 0x0a
static const uint16_t | CLOSE_NORMAL_CLOSURE = 1000
static const uint16_t | CLOSE_GOING_AWAY = 1001
static const uint16_t | CLOSE_PROTOCOL_ERROR = 1002
static const uint16_t | CLOSE_CANNOT_ACCEPT = 1003
static const uint16_t | CLOSE_NO_STATUS_CODE = 1005
static const uint16_t | CLOSE_CLOSED_ABNORMALLY = 1006
static const uint16_t | CLOSE_NOT_CONSISTENT = 1007
static const uint16_t | CLOSE_VIOLATED_POLICY = 1008
static const uint16_t | CLOSE_TOO_BIG = 1009
static const uint16_t | CLOSE_NO_EXTENSION = 1010
static const uint16_t | CLOSE_UNEXPECTED_CONDITION = 1011
static const uint16_t | CLOSE_SERVICE_RESTART = 1012
static const uint16_t | CLOSE_TRY_AGAIN_LATER = 1013
static const uint16_t | CLOSE_TLS_HANDSHAKE_FAILURE = 1015
static const uint8_t | SEND_TYPE_BINARY = 0x01
static const uint8_t | SEND_TYPE_TEXT = 0x02

## Member Function Documentation

## ◆ close()

void httpsserver::WebsocketHandler::close | ( | uint16_t | status = `CLOSE_NORMAL_CLOSURE`,
|  | std::string | message = `""`
| ) |  |

Close the Web socket.

Parameters

  [in] | status | The code passed in the close request.
  [in] | message | A clarification message on the close request.

## ◆ closed()

bool httpsserver::WebsocketHandler::closed | ( |  | ) |

Returns true if the connection has been closed, either by client or server

## ◆ send() [1/2]

void httpsserver::WebsocketHandler::send | ( | std::string | data,
|  | uint8_t | sendType = `SEND_TYPE_BINARY`
| ) |  |

Send data down the web socket See the WebSocket spec (RFC6455) section "6.1 Sending Data". We build a WebSocket frame, send the frame followed by the data.

Parameters

  [in] | data | The data to send down the WebSocket.
  [in] | sendType | The type of payload. Either SEND_TYPE_TEXT or SEND_TYPE_BINARY.

## ◆ send() [2/2]

void httpsserver::WebsocketHandler::send | ( | uint8_t * | data,
|  | uint16_t | length,
|  | uint8_t | sendType = `SEND_TYPE_BINARY`
| ) |  |

Send data down the web socket See the WebSocket spec (RFC6455) section "6.1 Sending Data". We build a WebSocket frame, send the frame followed by the data.

Parameters

  [in] | data | The data to send down the WebSocket.
  [in] | sendType | The type of payload. Either SEND_TYPE_TEXT or SEND_TYPE_BINARY.

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

- /home/frank/Projekte/esp32/https_server/esp32_https_server/src/WebsocketHandler.hpp
- /home/frank/Projekte/esp32/https_server/esp32_https_server/src/WebsocketHandler.cpp