Added basic websocket support

This commit is contained in:
Thulinma 2018-02-08 12:35:05 +01:00
parent f126b17ed1
commit dd976f7a7a
3 changed files with 190 additions and 0 deletions

22
lib/websocket.h Normal file
View file

@ -0,0 +1,22 @@
#pragma once
#include "http_parser.h"
#include "socket.h"
#include "util.h"
namespace HTTP{
class Websocket{
public:
Websocket(Socket::Connection &c, HTTP::Parser &h);
operator bool() const;
bool readFrame();
bool readLoop();
void sendFrame(const char * data, unsigned int len, unsigned int frameType = 1);
void sendFrame(const std::string & data);
Util::ResizeablePointer data;
uint8_t frameType;
private:
Socket::Connection &C;
HTTP::Parser &H;
};
}// namespace HTTP