回复统一设置为TEXT类型

This commit is contained in:
xiongziliang 2018-09-28 09:29:21 +08:00
parent 0c64389334
commit 40c1ea9b4c

View File

@ -135,10 +135,12 @@ protected:
_session->setOnBeforeSendCB([weakSelf](const Buffer::Ptr &buf){ _session->setOnBeforeSendCB([weakSelf](const Buffer::Ptr &buf){
auto strongSelf = weakSelf.lock(); auto strongSelf = weakSelf.lock();
if(strongSelf){ if(strongSelf){
bool mask_flag = strongSelf->_mask_flag; WebSocketHeader header;
strongSelf->_mask_flag = false; header._fin = true;
strongSelf->WebSocketSplitter::encode(*strongSelf,(uint8_t *)buf->data(),buf->size()); header._reserved = 0;
strongSelf->_mask_flag = mask_flag; header._opcode = WebSocketHeader::TEXT;
header._mask_flag = false;
strongSelf->WebSocketSplitter::encode(header,(uint8_t *)buf->data(),buf->size());
} }
return buf->size(); return buf->size();
}); });