cwWebSocket.cpp : Count number of received and sent msg's and track the size of largest msg recv'd and set.

This commit is contained in:
kevin 2023-12-29 14:06:17 -05:00
parent 82b60a873d
commit 9a6729b9b9

View File

@ -41,6 +41,12 @@ namespace cw
int _pollfdMaxN;
int _pollfdN;
unsigned _sendMsgCnt; // Count of msg's sent
unsigned _sendMaxByteN; // Max size across all sent msg's
unsigned _recvMsgCnt; // Count of msg's recv'd
unsigned _recvMaxByteN; // Max size across all recv'd msg's
} websock_t;
inline websock_t* _handleToPtr(handle_t h)
@ -264,7 +270,11 @@ namespace cw
//printf("recv: sess:%i proto:%s : %p : len:%li\n",sess->id,proto->name,ws->_cbFunc,len);
if( ws->_cbFunc != nullptr && len>0)
{
ws->_cbFunc(ws->_cbArg,proto->id,sess->id,kMessageTId,in,len);
ws->_recvMsgCnt += 1;
ws->_recvMaxByteN = std::max(ws->_recvMaxByteN,(unsigned)len);
}
break;
@ -321,6 +331,8 @@ namespace cw
{
msg_t* m;
cwLogInfo("Websock: sent: msgs:%i largest msg:%i - recv: msgs:%i largest msg:%i - LWS_PRE:%i",p->_sendMsgCnt,p->_sendMaxByteN,p->_recvMsgCnt,p->_recvMaxByteN,LWS_PRE);
if( p->_ctx != nullptr )
{
lws_context_destroy(p->_ctx);
@ -501,6 +513,9 @@ cw::rc_t cw::websock::send(handle_t h, unsigned protocolId, unsigned sessionId,
websock_t* p = _handleToPtr(h);
p->_q->push(m);
p->_sendMsgCnt += 1;
p->_sendMaxByteN = std::max(p->_sendMaxByteN,byteN);
return rc;
}