ESP32 HTTPS Server
httpsserver::WebsocketInputStreambuf Class Reference
Inheritance diagram for httpsserver::WebsocketInputStreambuf:
Collaboration diagram for httpsserver::WebsocketInputStreambuf:

Public Member Functions

 WebsocketInputStreambuf (ConnectionContext *con, size_t dataLength, uint8_t *_=nullptr, size_t bufferSize=2048)
 Create a Web Socket input record streambuf. More...
 
int_type underflow ()
 Handle the request to read data from the stream but we need more data from the source.
 
void discard ()
 Discard data for the record that has not yet been read. More...
 
size_t getRecordSize ()
 Get the size of the expected record. More...
 

Constructor & Destructor Documentation

◆ WebsocketInputStreambuf()

httpsserver::WebsocketInputStreambuf::WebsocketInputStreambuf ( ConnectionContext con,
size_t  dataLength,
uint8_t *  pMask = nullptr,
size_t  bufferSize = 2048 
)

Create a Web Socket input record streambuf.

Parameters
[in]socketThe socket we will be reading from.
[in]dataLengthThe size of a record.
[in]bufferSizeThe size of the buffer we wish to allocate to hold data.

Member Function Documentation

◆ discard()

void httpsserver::WebsocketInputStreambuf::discard ( )

Discard data for the record that has not yet been read.

We are working on a logical fixed length record in a socket stream. This means that we know in advance how big the record should be. If we have read some data from the stream and no longer wish to consume any further, we have to discard the remaining bytes in the stream before we can get to process the next record. This function discards the remainder of the data.

For example, if our record size is 1000 bytes and we have read 700 bytes and determine that we no longer need to continue, we can't just stop. There are still 300 bytes in the socket stream that need to be consumed/discarded before we can move on to the next record.

◆ getRecordSize()

size_t httpsserver::WebsocketInputStreambuf::getRecordSize ( )

Get the size of the expected record.

Returns
The size of the expected record.

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