diff --git a/cwIo.cpp b/cwIo.cpp index 00422ff..b7ebeca 100644 --- a/cwIo.cpp +++ b/cwIo.cpp @@ -3734,3 +3734,11 @@ void cw::io::uiReport( handle_t h ) if(_handleToUiHandle(h,uiH) == kOkRC ) ui::report(uiH); } + +void cw::io::uiRealTimeReport( handle_t h ) +{ + ui::handle_t uiH; + if(_handleToUiHandle(h,uiH) == kOkRC ) + ui::realTimeReport(uiH); +} + diff --git a/cwIo.h b/cwIo.h index 8462664..458c737 100644 --- a/cwIo.h +++ b/cwIo.h @@ -398,6 +398,7 @@ namespace cw rc_t uiSendValue( handle_t h, unsigned uuId, double value ); rc_t uiSendValue( handle_t h, unsigned uuId, const char* value ); + void uiRealTimeReport( handle_t h ); void uiReport( handle_t h ); } diff --git a/cwUi.cpp b/cwUi.cpp index ca383f7..d790d05 100644 --- a/cwUi.cpp +++ b/cwUi.cpp @@ -96,8 +96,7 @@ namespace cw unsigned* sessA; // sessA[ sessN ] array of wsSessId's unsigned sessN; unsigned sessAllocN; - - + bool msgCacheEnableFl; unsigned msgCacheSessId; char* msgCache; @@ -106,6 +105,9 @@ namespace cw unsigned msgCacheN; unsigned msgCacheMsgN; + unsigned sentMsgN; + unsigned recvMsgN; + } ui_t; ui_t* _handleToPtr( handle_t h ) @@ -326,6 +328,14 @@ namespace cw return nullptr; } + rc_t _send_callback( ui_t* p, unsigned wsSessId, const void* msg, unsigned msgByteN ) + { + p->sentMsgN += 1; + rc_t rc = p->sendCbFunc( p->sendCbArg, wsSessId, msg, msgByteN ); + + return rc; + } + rc_t _cache_flush( ui_t* p ) { @@ -338,7 +348,7 @@ namespace cw p->msgCache[ p->msgCacheN+1 ] = '}'; p->msgCache[ p->msgCacheN+2 ] = 0; - rc = p->sendCbFunc( p->sendCbArg, p->msgCacheSessId, p->msgCache, strlen(p->msgCache) ); + rc = _send_callback(p, p->msgCacheSessId, p->msgCache, strlen(p->msgCache) ); p->msgCacheN = snprintf(p->msgCache,p->msgCacheAllocN,"{\"op\":\"cache\", \"array\": ["); p->msgCacheSessId = kInvalidId; @@ -369,7 +379,7 @@ namespace cw rc = _cache_flush(p); if( msgByteN > p->msgCacheDataN ) - rc = p->sendCbFunc( p->sendCbArg, wsSessId, msg, msgByteN ); + rc = _send_callback(p, wsSessId, msg, msgByteN ); else { assert( p->msgCacheN + msgByteCommaN <= p->msgCacheDataN ); @@ -396,7 +406,7 @@ namespace cw if( p->msgCacheEnableFl ) rc = _cache_send( p, sessId, msg, msgByteCnt ); else - rc = p->sendCbFunc( p->sendCbArg, sessId, msg, msgByteCnt ); + rc = _send_callback(p, sessId, msg, msgByteCnt ); return rc; } @@ -1295,6 +1305,7 @@ cw::rc_t cw::ui::create( if((rc = _createFromObj( p, main_obj, kInvalidId, kRootUuId, kInvalidId )) != kOkRC ) rc = cwLogError(rc,"Create from UI resource failed."); } + h.set(p); @@ -1454,6 +1465,8 @@ cw::rc_t cw::ui::onReceive( handle_t h, unsigned wsSessId, const void* void_msg, while( (msg = _get_msg_from_recv_buffer(p)) != NULL ) { + p->recvMsgN += 1; + // parse the 'opId' from the message opId = _labelToOpId(msg); @@ -2110,12 +2123,15 @@ void cw::ui::report( handle_t h ) e->attr->child_ele(i)->to_string(p->buf,p->bufN); printf("%s, ", p->buf ); } - printf("\n"); - - } - + printf("\n"); + } } +void cw::ui::realTimeReport( handle_t h ) +{ + ui_t* p = _handleToPtr(h); + printf("UI msg count: recv:%i send:%i\n",p->recvMsgN,p->sentMsgN); +} namespace cw diff --git a/cwUi.h b/cwUi.h index 0c459df..4198109 100644 --- a/cwUi.h +++ b/cwUi.h @@ -171,7 +171,7 @@ namespace cw void report( handle_t h ); - + void realTimeReport( handle_t h ); namespace ws