ESP32 HTTPS Server
WebsocketInputStreambuf.hpp
1 #ifndef SRC_WEBSOCKETINPUTSTREAMBUF_HPP_
2 #define SRC_WEBSOCKETINPUTSTREAMBUF_HPP_
3 
4 #include <Arduino.h>
5 #include <lwip/def.h>
6 
7 #include <string>
8 #undef min
9 #undef max
10 #include <iostream>
11 #include <streambuf>
12 #include <sstream>
13 
14 #include <iostream>
15 
16 #include "HTTPSServerConstants.hpp"
17 #include "ConnectionContext.hpp"
18 
19 namespace httpsserver {
20 
21 class WebsocketInputStreambuf : public std::streambuf {
22 public:
24  ConnectionContext *con,
25  size_t dataLength,
26  uint8_t *_ = nullptr,
27  size_t bufferSize = 2048
28  );
29  virtual ~WebsocketInputStreambuf();
30 
31  int_type underflow();
32  void discard();
33  size_t getRecordSize();
34 
35 private:
36  char *_buffer;
37  ConnectionContext *_con;
38  size_t _dataLength;
39  size_t _bufferSize;
40  size_t _sizeRead;
41  uint8_t *_pMask;
42 
43 };
44 
45 } // namespace
46 
47 #endif
WebsocketInputStreambuf(ConnectionContext *con, size_t dataLength, uint8_t *_=nullptr, size_t bufferSize=2048)
Create a Web Socket input record streambuf.
Definition: WebsocketInputStreambuf.cpp:10
size_t getRecordSize()
Get the size of the expected record.
Definition: WebsocketInputStreambuf.cpp:60
Definition: WebsocketInputStreambuf.hpp:21
Internal class to handle the state of a connection.
Definition: ConnectionContext.hpp:18
void discard()
Discard data for the record that has not yet been read.
Definition: WebsocketInputStreambuf.cpp:45
Definition: ConnectionContext.cpp:3
int_type underflow()
Handle the request to read data from the stream but we need more data from the source.
Definition: WebsocketInputStreambuf.cpp:68