EHS Embedded HTTP Server  1.5.1.173
RawSocketHandler Class Referenceabstract

Helper class for performing raw socket IO. More...

#include <ehs.h>

Public Member Functions

virtual bool OnData (EHSConnection *conn, std::string data)=0
 Handle raw data. More...
 
virtual void OnConnect (EHSConnection *conn)=0
 Handle connect event. More...
 
virtual void OnDisconnect (EHSConnection *conn)=0
 Handle disconnect event. More...
 

Detailed Description

Helper class for performing raw socket IO.

This class abstracts an interface to an external helper which which facilitates binary IO on a connection (for implementing WebSockets). In order to use raw IO, one first has to register an instance of this class using SetRawSocketHandler() and then produce a HttpResponse code 101. After sending this HttpResponse, EHS switches the corresponding connection into raw Mode, which does no further message parsing on received data, but invokes the OnData method whenever data arrives from the client.

Examples:
ehs_wsgate.cpp.

Definition at line 61 of file ehs.h.

Member Function Documentation

◆ OnConnect()

virtual void OnConnect ( EHSConnection conn)
pure virtual

Handle connect event.

Called by EHS, if an EHSConnection has switched into raw mode.

Parameters
connThe EHSConnection on which the event has happened.

◆ OnData()

virtual bool OnData ( EHSConnection conn,
std::string  data 
)
pure virtual

Handle raw data.

Called by EHS, if an EHSConnection is in raw mode.

Parameters
connThe EHSConnection on which the data was received.
dataThe received data.
Returns
true, if the connection should be kept open.

◆ OnDisconnect()

virtual void OnDisconnect ( EHSConnection conn)
pure virtual

Handle disconnect event.

Called by EHS, if an EHSConnection is about to be closed.

Parameters
connThe EHSConnection on which the event has happened.

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