修复websock相关bug

This commit is contained in:
xiongziliang 2018-09-29 14:54:49 +08:00
parent 9fdf05bed0
commit cacd241223
3 changed files with 6 additions and 5 deletions

View File

@ -101,9 +101,10 @@ public:
} }
//每隔一段时间触发,用来做超时管理 //每隔一段时间触发,用来做超时管理
void onManager() override{ void onManager() override{
HttpSessionType::onManager();
if(_session){ if(_session){
_session->onManager(); _session->onManager();
}else{
HttpSessionType::onManager();
} }
} }

View File

@ -163,7 +163,7 @@ void WebSocketSplitter::onPlayloadData(uint8_t *ptr, uint64_t len) {
onWebSocketDecodePlayload(*this, _mask_flag ? ptr - len : ptr, len, _playload_offset); onWebSocketDecodePlayload(*this, _mask_flag ? ptr - len : ptr, len, _playload_offset);
} }
void WebSocketSplitter::encode(const WebSocketHeader &header,uint8_t *data, uint64_t len) { void WebSocketSplitter::encode(const WebSocketHeader &header,uint8_t *data, const uint64_t len) {
string ret; string ret;
uint8_t byte = header._fin << 7 | ((header._reserved & 0x07) << 4) | (header._opcode & 0x0F) ; uint8_t byte = header._fin << 7 | ((header._reserved & 0x07) << 4) | (header._opcode & 0x0F) ;
@ -179,8 +179,8 @@ void WebSocketSplitter::encode(const WebSocketHeader &header,uint8_t *data, uint
byte |= 126; byte |= 126;
ret.push_back(byte); ret.push_back(byte);
uint16_t len = htons(len); auto len_low = htons(len);
ret.append((char *)&len,2); ret.append((char *)&len_low,2);
}else{ }else{
byte |= 127; byte |= 127;
ret.push_back(byte); ret.push_back(byte);

View File

@ -91,7 +91,7 @@ public:
* @param data * @param data
* @param len * @param len
*/ */
void encode(const WebSocketHeader &header,uint8_t *data,uint64_t len); void encode(const WebSocketHeader &header,uint8_t *data,const uint64_t len);
protected: protected:
/** /**
* webSocket数据包包头onWebSocketDecodePlayload回调 * webSocket数据包包头onWebSocketDecodePlayload回调