Simple WebSocket server library.
Dependents: WebSocketServerTest
Diff: WebSocketConnection.h
- Revision:
- 0:a816c25e83ed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WebSocketConnection.h Mon Mar 16 10:13:30 2015 +0000 @@ -0,0 +1,31 @@ +#ifndef _WEB_SOCKET_CONNECTION_H_ +#define _WEB_SOCKET_CONNECTION_H_ + +#include "TCPSocketServer.h" +#include "WebSocketHandler.h" +#include <string> +#include <map> + +class WebSocketServer; + +class WebSocketConnection +{ +public: + WebSocketConnection(WebSocketServer* server); + virtual ~WebSocketConnection(); + + void run(); + TCPSocketConnection& getTCPSocketConnection() { return mConnection; } + +private: + bool handleHTTP(char* buf, int size); + bool handleWebSocket(char* buf, int size); + bool sendUpgradeResponse(char* key); + + WebSocketServer* mServer; + TCPSocketConnection mConnection; + WebSocketHandler* mHandler; + bool mPrevFin; +}; + +#endif