Orbit Framework
An ultra-modern, asynchronous, cross-platform C++ Web Framework.
Loading...
Searching...
No Matches
http::websocket::WebSocketConnection Class Reference

Represents an active WebSocket connection. More...

#include <WebSocketConnection.hpp>

Public Member Functions

 WebSocketConnection (server::Connection &underlying_connection, bool enable_deflate=false)
 
 ~WebSocketConnection ()
 
void on_message (std::function< void(const std::string &)> handler)
 Registers a callback to be called when a message is received.
 
void on_close (std::function< void()> handler)
 Registers a callback to be called when the connection is closed.
 
void send (const std::string &message)
 Sends a text message over the WebSocket connection.
 
void close ()
 Closes the WebSocket connection gracefully.
 
void process_raw_data (std::vector< char > &buffer)
 

Detailed Description

Constructor & Destructor Documentation

◆ WebSocketConnection()

http::websocket::WebSocketConnection::WebSocketConnection ( server::Connection underlying_connection,
bool  enable_deflate = false 
)
explicit

◆ ~WebSocketConnection()

http::websocket::WebSocketConnection::~WebSocketConnection ( )

Member Function Documentation

◆ close()

void http::websocket::WebSocketConnection::close ( )

Closes the WebSocket connection gracefully.

◆ on_close()

void http::websocket::WebSocketConnection::on_close ( std::function< void()>  handler)

Registers a callback to be called when the connection is closed.

Parameters
handlerThe callback function.

◆ on_message()

void http::websocket::WebSocketConnection::on_message ( std::function< void(const std::string &)>  handler)

Registers a callback to be called when a message is received.

Parameters
handlerThe callback function.

◆ process_raw_data()

void http::websocket::WebSocketConnection::process_raw_data ( std::vector< char > &  buffer)

◆ send()

void http::websocket::WebSocketConnection::send ( const std::string &  message)

Sends a text message over the WebSocket connection.

Parameters
messageThe message to send.
Examples
/home/runner/work/orbit-framework/orbit-framework/include/orbit/websocket/EventRouter.hpp.

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