You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.5 KiB
87 lines
2.5 KiB
#ifndef __SERVLET_WEB_SOCKET_CLIENT_HANDLER_HEADER__
|
|
#define __SERVLET_WEB_SOCKET_CLIENT_HANDLER_HEADER__
|
|
|
|
#include "../../components/base/basicThread.h"
|
|
#include "../../alg/generic/libzip.h"
|
|
|
|
|
|
#include <sys/types.h> /* See NOTES */
|
|
#include <sys/socket.h>
|
|
#include <poll.h>
|
|
|
|
#include <vector>
|
|
|
|
typedef struct S_WS_FRAME_HEADER_B0{
|
|
union {
|
|
uint8_t byte;
|
|
struct{
|
|
uint8_t OPCODE: 4;
|
|
uint8_t RSV3: 1;
|
|
uint8_t RSV2: 1;
|
|
uint8_t RSV1: 1;
|
|
uint8_t FIN: 1;
|
|
} bits;
|
|
};
|
|
} WS_FRAME_HEADER_B0;
|
|
|
|
typedef struct S_WS_FRAME_HEADER_B1{
|
|
union {
|
|
uint8_t byte;
|
|
struct{
|
|
uint8_t PLEN0: 7;
|
|
uint8_t MASK: 1;
|
|
} bits;
|
|
};
|
|
} WS_FRAME_HEADER_B1;
|
|
|
|
typedef struct S_WS_FRAME_HEADER{
|
|
union {
|
|
uint16_t word;
|
|
struct{
|
|
uint16_t OPCODE: 4;
|
|
uint16_t RSV3: 1;
|
|
uint16_t RSV2: 1;
|
|
uint16_t RSV1: 1;
|
|
uint16_t FIN: 1;
|
|
uint16_t PLEN0: 7;
|
|
uint16_t MASK: 1;
|
|
}bits;
|
|
};
|
|
uint16_t PLE_MASK1;
|
|
uint16_t PLE_MASK2;
|
|
uint16_t PLE3;
|
|
uint16_t PLE4;
|
|
uint16_t MASK3;
|
|
uint16_t MASK4;
|
|
} WS_FRAME_HEADER;
|
|
|
|
typedef enum E_WS_OPCODE{
|
|
WS_OC_CONTINUATION = 0x0,
|
|
WS_OC_TEXT = 0x1,
|
|
WS_OC_BINARY = 0x2,
|
|
WS_OC_CLOSE = 0x8,
|
|
WS_OC_PING = 0x9,
|
|
WS_OC_PONG = 0xA
|
|
} WS_OPCODE;
|
|
|
|
|
|
class servletWS;
|
|
|
|
class servletClientHandlerWS: public basicThread{
|
|
private:
|
|
basicLogCollection * m_pLog;
|
|
int m_iSocketFID;
|
|
servletWS * m_pParent;
|
|
zipDataPackage * m_pDeflatener;
|
|
bool m_bDeflatePerMessage;
|
|
bool parseFrame(){ return true; };
|
|
bool assembleFrame( bool FIN, bool RSV1, bool RSV2, bool RSV3, WS_OPCODE code, uint8_t *in_buffer, size_t in_size, uint8_t *&out_buffer, size_t &out_size, bool bmask=false, uint32_t mask=0xffff );
|
|
public:
|
|
explicit servletClientHandlerWS( servletWS *pPtr, int Socket );
|
|
~servletClientHandlerWS();
|
|
virtual void m_fThreadProc( void );
|
|
};
|
|
|
|
typedef std::vector<servletClientHandlerWS*> vectorClientHandlerWS;
|
|
|
|
#endif
|