cwUi.h/cpp : Added findElementUuId( h, appId) to return uuid of the first occurence of an element with appId.
This commit is contained in:
parent
e1a931c2a1
commit
8f4455ae95
30
cwUi.cpp
30
cwUi.cpp
@ -212,6 +212,15 @@ namespace cw
|
|||||||
return kInvalidId;
|
return kInvalidId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned _findElementUuId( ui_t* p, unsigned appId )
|
||||||
|
{
|
||||||
|
for(unsigned i=0; i<p->eleN; ++i)
|
||||||
|
if( p->eleA[i]->appId == appId )
|
||||||
|
return p->eleA[i]->uuId;
|
||||||
|
|
||||||
|
return kInvalidId;
|
||||||
|
}
|
||||||
|
|
||||||
const char* _findEleEleName( ui_t* p, unsigned uuId )
|
const char* _findEleEleName( ui_t* p, unsigned uuId )
|
||||||
{
|
{
|
||||||
for(unsigned i=0; i<p->eleN; ++i)
|
for(unsigned i=0; i<p->eleN; ++i)
|
||||||
@ -229,7 +238,15 @@ namespace cw
|
|||||||
if( p->sendCbFunc != nullptr )
|
if( p->sendCbFunc != nullptr )
|
||||||
{
|
{
|
||||||
unsigned msgByteN = msg==nullptr ? 0 : strlen(msg);
|
unsigned msgByteN = msg==nullptr ? 0 : strlen(msg);
|
||||||
return p->sendCbFunc( p->sendCbArg, wsSessId, msg, msgByteN );
|
|
||||||
|
if( wsSessId != kInvalidId )
|
||||||
|
rc = p->sendCbFunc( p->sendCbArg, wsSessId, msg, msgByteN );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for(unsigned i=0; i<p->sessN; ++i)
|
||||||
|
rc = p->sendCbFunc( p->sendCbArg, p->sessA[i], msg, msgByteN );
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
@ -723,7 +740,8 @@ namespace cw
|
|||||||
if( snprintf(mbuf,mbufN,mFmt,uuId,vbuf) >= mbufN-1 )
|
if( snprintf(mbuf,mbufN,mFmt,uuId,vbuf) >= mbufN-1 )
|
||||||
return cwLogError(kBufTooSmallRC,"The msg buffer is too small.");
|
return cwLogError(kBufTooSmallRC,"The msg buffer is too small.");
|
||||||
|
|
||||||
p->sendCbFunc(p->sendCbArg,wsSessId,mbuf,strlen(mbuf));
|
//p->sendCbFunc(p->sendCbArg,wsSessId,mbuf,strlen(mbuf));
|
||||||
|
_websockSend(p,wsSessId,mbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
@ -977,6 +995,14 @@ unsigned cw::ui::findElementUuId( handle_t h, const char* eleName )
|
|||||||
return _findElementUuId(p,eleName);
|
return _findElementUuId(p,eleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned cw::ui::findElementUuId( handle_t h, unsigned appId )
|
||||||
|
{
|
||||||
|
ui_t* p = _handleToPtr(h);
|
||||||
|
|
||||||
|
return _findElementUuId(p,appId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned cw::ui::findElementAppId( handle_t h, unsigned uuId )
|
unsigned cw::ui::findElementAppId( handle_t h, unsigned uuId )
|
||||||
{
|
{
|
||||||
ui_t* p = _handleToPtr(h);
|
ui_t* p = _handleToPtr(h);
|
||||||
|
4
cwUi.h
4
cwUi.h
@ -45,8 +45,9 @@ namespace cw
|
|||||||
const char* findElementName( handle_t h, unsigned uuId );
|
const char* findElementName( handle_t h, unsigned uuId );
|
||||||
unsigned findElementAppId( handle_t h, unsigned uuId );
|
unsigned findElementAppId( handle_t h, unsigned uuId );
|
||||||
|
|
||||||
// Return the uuid of the first matching 'eleName'.
|
// Return the uuid of the first matching 'eleName' or 'appId'.
|
||||||
unsigned findElementUuId( handle_t h, const char* eleName );
|
unsigned findElementUuId( handle_t h, const char* eleName );
|
||||||
|
unsigned findElementUuId( handle_t h, unsigned appId );
|
||||||
|
|
||||||
rc_t createFromObject( handle_t h, const object_t* o, unsigned wsSessId, unsigned parentUuId=kInvalidId, const char* eleName=nullptr);
|
rc_t createFromObject( handle_t h, const object_t* o, unsigned wsSessId, unsigned parentUuId=kInvalidId, const char* eleName=nullptr);
|
||||||
rc_t createFromFile( handle_t h, const char* fn, unsigned wsSessId, unsigned parentUuId=kInvalidId);
|
rc_t createFromFile( handle_t h, const char* fn, unsigned wsSessId, unsigned parentUuId=kInvalidId);
|
||||||
@ -77,6 +78,7 @@ namespace cw
|
|||||||
rc_t registerAppIdMap( handle_t h, const appIdMap_t* map, unsigned mapN );
|
rc_t registerAppIdMap( handle_t h, const appIdMap_t* map, unsigned mapN );
|
||||||
|
|
||||||
// Send a value from the application to the UI via a JSON messages.
|
// Send a value from the application to the UI via a JSON messages.
|
||||||
|
// Set wsSessId to kInvalidId to send to all sessions.
|
||||||
rc_t sendValueBool( handle_t h, unsigned wsSessId, unsigned uuId, bool value );
|
rc_t sendValueBool( handle_t h, unsigned wsSessId, unsigned uuId, bool value );
|
||||||
rc_t sendValueInt( handle_t h, unsigned wsSessId, unsigned uuId, int value );
|
rc_t sendValueInt( handle_t h, unsigned wsSessId, unsigned uuId, int value );
|
||||||
rc_t sendValueUInt( handle_t h, unsigned wsSessId, unsigned uuId, unsigned value );
|
rc_t sendValueUInt( handle_t h, unsigned wsSessId, unsigned uuId, unsigned value );
|
||||||
|
Loading…
Reference in New Issue
Block a user