2020-03-23 14:48:49 +00:00
|
|
|
#include "cwCommon.h"
|
|
|
|
#include "cwLog.h"
|
|
|
|
#include "cwCommonImpl.h"
|
|
|
|
#include "cwMem.h"
|
2020-04-07 20:24:34 +00:00
|
|
|
#include "cwThread.h"
|
|
|
|
#include "cwWebSock.h"
|
2020-04-21 21:56:38 +00:00
|
|
|
#include "cwObject.h"
|
2020-03-23 14:48:49 +00:00
|
|
|
#include "cwUi.h"
|
|
|
|
#include "cwUiTest.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace cw
|
|
|
|
{
|
|
|
|
namespace ui
|
|
|
|
{
|
|
|
|
typedef struct ui_test_str
|
|
|
|
{
|
2021-01-20 18:10:56 +00:00
|
|
|
|
|
|
|
//const char* uiCfgFn; // Resource file name
|
|
|
|
srv::handle_t wsUiSrvH; //
|
2020-04-28 12:42:16 +00:00
|
|
|
|
|
|
|
std::atomic<bool> quitFl;
|
2021-01-20 18:10:56 +00:00
|
|
|
|
|
|
|
// Application values
|
2020-04-24 14:20:25 +00:00
|
|
|
bool appCheckFl;
|
2020-04-28 12:42:16 +00:00
|
|
|
unsigned appSelOptAppId;
|
2020-04-24 14:20:25 +00:00
|
|
|
int appInteger;
|
|
|
|
float appFloat;
|
|
|
|
int appProgress;
|
|
|
|
char* appString;
|
2020-04-28 12:42:16 +00:00
|
|
|
bool appCheck1Fl;
|
|
|
|
bool appCheck2Fl;
|
|
|
|
float appNumb;
|
|
|
|
unsigned appSelId;
|
2021-10-12 20:52:08 +00:00
|
|
|
|
|
|
|
unsigned myPanelUuId;
|
|
|
|
unsigned logUuId;
|
2021-11-01 14:11:27 +00:00
|
|
|
|
|
|
|
const object_t* listEleCfg;
|
2020-04-24 14:20:25 +00:00
|
|
|
|
2020-03-23 14:48:49 +00:00
|
|
|
} ui_test_t;
|
|
|
|
|
2021-01-20 18:10:56 +00:00
|
|
|
// Application Id's for UI elements
|
2020-03-23 14:48:49 +00:00
|
|
|
enum
|
|
|
|
{
|
2021-01-20 18:10:56 +00:00
|
|
|
// Programatically created UI elements
|
2020-03-23 14:48:49 +00:00
|
|
|
kDivId,
|
|
|
|
kCheckId,
|
|
|
|
kSelectId,
|
|
|
|
kOption0Id,
|
|
|
|
kOption1Id,
|
|
|
|
kOption2Id,
|
|
|
|
kOption3Id,
|
|
|
|
kStringId,
|
2020-04-24 14:20:25 +00:00
|
|
|
kIntegerId,
|
|
|
|
kFloatId,
|
2020-04-06 23:17:04 +00:00
|
|
|
kProgressId,
|
2021-10-12 20:52:08 +00:00
|
|
|
kLogId,
|
2020-04-06 23:17:04 +00:00
|
|
|
|
2021-01-20 18:10:56 +00:00
|
|
|
// Resource Based elements
|
2021-11-01 14:11:27 +00:00
|
|
|
kQuitBtnId,
|
2020-04-06 23:17:04 +00:00
|
|
|
kPanelDivId,
|
2020-04-28 12:42:16 +00:00
|
|
|
kPanelBtn1Id,
|
|
|
|
kPanelCheck1Id,
|
|
|
|
kPanelBtn2Id,
|
|
|
|
kPanelCheck2Id,
|
|
|
|
kPanelFloaterId,
|
|
|
|
kSelId,
|
|
|
|
kOpt1Id,
|
|
|
|
kOpt2Id,
|
2021-11-01 14:11:27 +00:00
|
|
|
kOpt3Id,
|
|
|
|
kListId
|
2020-03-23 14:48:49 +00:00
|
|
|
};
|
|
|
|
|
2020-03-31 17:10:45 +00:00
|
|
|
rc_t _uiTestCreateUi( ui_test_t* p, unsigned wsSessId )
|
2020-03-23 14:48:49 +00:00
|
|
|
{
|
|
|
|
rc_t rc = kOkRC;
|
|
|
|
unsigned uuid = kInvalidId;
|
|
|
|
unsigned selUuId = kInvalidId;
|
|
|
|
|
2020-04-07 20:24:34 +00:00
|
|
|
|
|
|
|
handle_t uiH = srv::uiHandle(p->wsUiSrvH);
|
2020-04-06 23:17:04 +00:00
|
|
|
|
2021-01-20 18:10:56 +00:00
|
|
|
// Create a UI elements programatically.
|
2020-04-06 23:17:04 +00:00
|
|
|
|
2021-10-12 20:52:08 +00:00
|
|
|
if((rc = createDiv( uiH, p->myPanelUuId, wsSessId, kInvalidId, "myDivId", kDivId, "divClass", "My Panel" )) != kOkRC )
|
2020-03-23 14:48:49 +00:00
|
|
|
goto errLabel;
|
2020-04-24 20:37:15 +00:00
|
|
|
|
2021-10-12 20:52:08 +00:00
|
|
|
if((rc = createCheck( uiH, uuid, wsSessId, p->myPanelUuId, "myCheckId", kCheckId, "checkClass", "Check Me", true )) != kOkRC )
|
2020-03-23 14:48:49 +00:00
|
|
|
goto errLabel;
|
|
|
|
|
2021-10-12 20:52:08 +00:00
|
|
|
if((rc = createSelect( uiH, selUuId, wsSessId, p->myPanelUuId, "mySelId", kSelectId, "selClass", "Select" )) != kOkRC )
|
2020-03-23 14:48:49 +00:00
|
|
|
goto errLabel;
|
|
|
|
|
2020-04-07 20:24:34 +00:00
|
|
|
if((rc = createOption( uiH, uuid, wsSessId, selUuId, "myOpt0Id", kOption0Id, "optClass", "Option 0" )) != kOkRC )
|
2020-03-23 14:48:49 +00:00
|
|
|
goto errLabel;
|
|
|
|
|
2020-04-07 20:24:34 +00:00
|
|
|
if((rc = createOption( uiH, uuid, wsSessId, selUuId, "myOpt1Id", kOption1Id, "optClass", "Option 1" )) != kOkRC )
|
2020-03-23 14:48:49 +00:00
|
|
|
goto errLabel;
|
|
|
|
|
2020-04-07 20:24:34 +00:00
|
|
|
if((rc = createOption( uiH, uuid, wsSessId, selUuId, "myOpt2Id", kOption2Id, "optClass", "Option 2" )) != kOkRC )
|
2020-03-23 14:48:49 +00:00
|
|
|
goto errLabel;
|
|
|
|
|
2021-10-12 20:52:08 +00:00
|
|
|
if((rc = createStr( uiH, uuid, wsSessId, p->myPanelUuId, "myStringId", kStringId, "stringClass", "String", "a string value" )) != kOkRC )
|
2020-03-23 14:48:49 +00:00
|
|
|
goto errLabel;
|
|
|
|
|
2021-10-12 20:52:08 +00:00
|
|
|
if((rc = createNumb( uiH, uuid, wsSessId, p->myPanelUuId, "myIntegerId", kIntegerId, "integerClass", "Integer", 0, 100, 1, 0, 10 )) != kOkRC )
|
2020-04-24 14:20:25 +00:00
|
|
|
goto errLabel;
|
|
|
|
|
2021-10-12 20:52:08 +00:00
|
|
|
if((rc = createNumb( uiH, uuid, wsSessId, p->myPanelUuId, "myFloatId", kFloatId, "floatClass", "Float", 0.53, 100.97, 1.0, 5, 10.0 )) != kOkRC )
|
|
|
|
goto errLabel;
|
|
|
|
|
|
|
|
if((rc = createProg( uiH, uuid, wsSessId, p->myPanelUuId, "myProgressId", kProgressId, "progressClass", "Progress", 0, 10, 5 )) != kOkRC )
|
2020-03-23 14:48:49 +00:00
|
|
|
goto errLabel;
|
2021-10-12 20:52:08 +00:00
|
|
|
|
2020-03-23 14:48:49 +00:00
|
|
|
|
2021-10-12 20:52:08 +00:00
|
|
|
if((rc = createLog( uiH, p->logUuId, wsSessId, p->myPanelUuId, "myLogId", kLogId, "logClass", "My Log (click toggles auto-scroll)" )) != kOkRC )
|
2020-03-31 17:10:45 +00:00
|
|
|
goto errLabel;
|
|
|
|
|
2020-03-23 14:48:49 +00:00
|
|
|
errLabel:
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2020-04-28 12:42:16 +00:00
|
|
|
void _print_state( ui_test_t* p )
|
|
|
|
{
|
|
|
|
printf("check:%i sel:%i int:%i flt:%f prog:%i str:%s chk1:%i chk2:%i numb:%f sel:%i\n",
|
|
|
|
p->appCheckFl,
|
|
|
|
p->appSelOptAppId,
|
|
|
|
p->appInteger,
|
|
|
|
p->appFloat,
|
|
|
|
p->appProgress,
|
|
|
|
p->appString,
|
|
|
|
p->appCheck1Fl,
|
|
|
|
p->appCheck2Fl,
|
|
|
|
p->appNumb,
|
|
|
|
p->appSelId);
|
|
|
|
}
|
|
|
|
|
2021-10-12 20:52:08 +00:00
|
|
|
|
2021-11-01 14:11:27 +00:00
|
|
|
rc_t _insert_list_ele( ui_test_t* p, unsigned wsSessId )
|
2021-10-12 20:52:08 +00:00
|
|
|
{
|
2021-11-01 14:11:27 +00:00
|
|
|
rc_t rc = kOkRC;
|
2021-10-12 20:52:08 +00:00
|
|
|
|
2021-11-01 14:11:27 +00:00
|
|
|
if( p->listEleCfg != nullptr )
|
|
|
|
{
|
|
|
|
handle_t uiH = srv::uiHandle(p->wsUiSrvH);
|
|
|
|
unsigned listUuId = findElementUuId( uiH, kListId );
|
2021-10-12 20:52:08 +00:00
|
|
|
|
2021-11-01 14:11:27 +00:00
|
|
|
printf("list uuid:%i\n",listUuId);
|
|
|
|
|
|
|
|
rc = createFromObject( uiH, p->listEleCfg, wsSessId, listUuId );
|
|
|
|
}
|
|
|
|
|
2021-10-12 20:52:08 +00:00
|
|
|
return rc;
|
|
|
|
}
|
2020-04-28 12:42:16 +00:00
|
|
|
|
2021-11-01 14:11:27 +00:00
|
|
|
|
|
|
|
rc_t _insert_log_line( ui_test_t* p, unsigned wsSessId, const char* text )
|
|
|
|
{
|
|
|
|
return ui::setLogLine( srv::uiHandle(p->wsUiSrvH), wsSessId, p->logUuId, text );
|
|
|
|
}
|
|
|
|
|
2020-03-31 17:10:45 +00:00
|
|
|
rc_t _handleUiValueMsg( ui_test_t* p, unsigned wsSessId, unsigned parentAppId, unsigned uuId, unsigned appId, const value_t* v )
|
2020-03-23 14:48:49 +00:00
|
|
|
{
|
|
|
|
rc_t rc = kOkRC;
|
|
|
|
|
|
|
|
switch( appId )
|
|
|
|
{
|
2021-11-01 14:11:27 +00:00
|
|
|
case kQuitBtnId:
|
2020-04-28 12:42:16 +00:00
|
|
|
p->quitFl.store(true);
|
2020-03-23 14:48:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kCheckId:
|
|
|
|
printf("Check:%i\n", v->u.b);
|
2020-04-24 14:20:25 +00:00
|
|
|
p->appCheckFl = v->u.b;
|
2021-10-12 20:52:08 +00:00
|
|
|
_insert_log_line( p, wsSessId, "check!\n" );
|
2020-03-23 14:48:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kSelectId:
|
2020-04-28 12:42:16 +00:00
|
|
|
printf("Selected: option appId:%i\n", v->u.i);
|
|
|
|
p->appSelOptAppId = v->u.i;
|
2020-03-23 14:48:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kStringId:
|
|
|
|
printf("String: %s\n",v->u.s);
|
2020-04-24 14:20:25 +00:00
|
|
|
mem::release(p->appString);
|
|
|
|
if( v->u.s != nullptr )
|
|
|
|
p->appString = mem::duplStr(v->u.s);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kIntegerId:
|
2021-10-12 20:52:08 +00:00
|
|
|
{
|
|
|
|
printf("Integer: %i\n",v->u.i);
|
|
|
|
p->appInteger = v->u.i;
|
|
|
|
|
|
|
|
handle_t uiH = srv::uiHandle(p->wsUiSrvH);
|
|
|
|
unsigned progUuId = findElementUuId( uiH, p->myPanelUuId, kProgressId );
|
|
|
|
sendValueInt( uiH, wsSessId, progUuId, v->u.i );
|
|
|
|
}
|
2020-04-24 14:20:25 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kFloatId:
|
|
|
|
printf("Float: %f\n",v->u.f);
|
|
|
|
p->appFloat = v->u.f;
|
2020-04-28 12:42:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
case kPanelBtn1Id:
|
|
|
|
printf("Button 1\n");
|
|
|
|
_print_state(p);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kPanelCheck1Id:
|
|
|
|
printf("check 1: %i\n",v->u.b);
|
|
|
|
p->appCheck1Fl = v->u.b;
|
2021-11-01 14:11:27 +00:00
|
|
|
ui::report( srv::uiHandle(p->wsUiSrvH) );
|
|
|
|
|
2020-04-28 12:42:16 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kPanelBtn2Id:
|
|
|
|
printf("Button 2\n");
|
|
|
|
_print_state(p);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kPanelCheck2Id:
|
|
|
|
printf("check 1: %i\n",v->u.b);
|
|
|
|
p->appCheck1Fl = v->u.b;
|
2021-11-01 14:11:27 +00:00
|
|
|
_insert_list_ele( p, wsSessId );
|
2020-04-28 12:42:16 +00:00
|
|
|
break;
|
2020-03-23 14:48:49 +00:00
|
|
|
|
2020-04-28 12:42:16 +00:00
|
|
|
case kPanelFloaterId:
|
|
|
|
printf("numb: %f\n",v->u.f);
|
|
|
|
p->appNumb = v->u.f;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kSelId:
|
|
|
|
printf("sel: %i\n",v->u.i);
|
|
|
|
p->appSelId = v->u.i;
|
|
|
|
break;
|
2020-03-23 14:48:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
2020-04-24 14:20:25 +00:00
|
|
|
|
|
|
|
rc_t _handleUiEchoMsg( ui_test_t* p, unsigned wsSessId, unsigned parentAppId, unsigned uuId, unsigned appId )
|
|
|
|
{
|
|
|
|
rc_t rc = kOkRC;
|
|
|
|
|
|
|
|
switch( appId )
|
|
|
|
{
|
|
|
|
case kCheckId:
|
|
|
|
sendValueBool( uiHandle( p->wsUiSrvH ), wsSessId, uuId, p->appCheckFl );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kSelectId:
|
2020-04-28 12:42:16 +00:00
|
|
|
sendValueInt( uiHandle( p->wsUiSrvH ), wsSessId, uuId, p->appSelOptAppId );
|
2020-04-24 14:20:25 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kStringId:
|
|
|
|
sendValueString( uiHandle( p->wsUiSrvH ), wsSessId, uuId, p->appString );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kIntegerId:
|
|
|
|
sendValueInt( uiHandle( p->wsUiSrvH ), wsSessId, uuId, p->appInteger );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kFloatId:
|
|
|
|
sendValueFloat( uiHandle( p->wsUiSrvH ), wsSessId, uuId, p->appFloat );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kProgressId:
|
|
|
|
sendValueInt( uiHandle( p->wsUiSrvH ), wsSessId, uuId, p->appProgress );
|
|
|
|
break;
|
2020-04-28 12:42:16 +00:00
|
|
|
|
|
|
|
case kPanelCheck1Id:
|
|
|
|
sendValueBool( uiHandle( p->wsUiSrvH ), wsSessId, uuId, p->appCheck1Fl);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kPanelCheck2Id:
|
|
|
|
sendValueBool( uiHandle( p->wsUiSrvH ), wsSessId, uuId, p->appCheck2Fl);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kPanelFloaterId:
|
|
|
|
sendValueFloat( uiHandle( p->wsUiSrvH ), wsSessId, uuId, p->appNumb );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kSelId:
|
|
|
|
sendValueInt( uiHandle( p->wsUiSrvH ), wsSessId, uuId, p->appSelId );
|
|
|
|
break;
|
2020-04-24 14:20:25 +00:00
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
2020-03-23 14:48:49 +00:00
|
|
|
|
2020-03-31 17:10:45 +00:00
|
|
|
|
2020-04-24 14:20:25 +00:00
|
|
|
|
2020-03-31 17:10:45 +00:00
|
|
|
// This function is called by the websocket with messages comring from a remote UI.
|
|
|
|
rc_t _uiTestCallback( void* cbArg, unsigned wsSessId, opId_t opId, unsigned parentAppId, unsigned uuId, unsigned appId, const value_t* v )
|
2020-03-23 14:48:49 +00:00
|
|
|
{
|
|
|
|
ui_test_t* p = (ui_test_t*)cbArg;
|
|
|
|
|
|
|
|
switch( opId )
|
|
|
|
{
|
|
|
|
case kConnectOpId:
|
2020-04-24 20:37:15 +00:00
|
|
|
cwLogInfo("UI Test Connect: wsSessId:%i.",wsSessId);
|
2020-03-23 14:48:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kDisconnectOpId:
|
2020-04-24 20:37:15 +00:00
|
|
|
cwLogInfo("UI Test Disconnect: wsSessId:%i.",wsSessId);
|
2020-03-23 14:48:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kInitOpId:
|
2021-11-01 14:11:27 +00:00
|
|
|
//_uiTestCreateUi(p,wsSessId);
|
2020-03-23 14:48:49 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kValueOpId:
|
2020-03-31 17:10:45 +00:00
|
|
|
_handleUiValueMsg( p, wsSessId, parentAppId, uuId, appId, v );
|
2020-03-23 14:48:49 +00:00
|
|
|
break;
|
|
|
|
|
2020-04-24 14:20:25 +00:00
|
|
|
case kEchoOpId:
|
|
|
|
_handleUiEchoMsg( p, wsSessId, parentAppId, uuId, appId );
|
|
|
|
break;
|
|
|
|
|
2020-03-23 14:48:49 +00:00
|
|
|
case kInvalidOpId:
|
|
|
|
// fall through
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
return kOkRC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-20 18:10:56 +00:00
|
|
|
cw::rc_t cw::ui::test( const object_t* cfg )
|
2020-03-23 14:48:49 +00:00
|
|
|
{
|
2021-01-20 18:10:56 +00:00
|
|
|
rc_t rc = kOkRC;
|
|
|
|
ui::ws::args_t args = {};
|
|
|
|
|
|
|
|
// Application Id's for the resource based UI elements.
|
2020-04-27 12:14:26 +00:00
|
|
|
appIdMap_t mapA[] =
|
|
|
|
{
|
2021-11-01 14:11:27 +00:00
|
|
|
{ kRootAppId, kQuitBtnId, "myQuitBtnId" },
|
2020-04-28 12:42:16 +00:00
|
|
|
{ kRootAppId, kPanelDivId, "panelDivId" },
|
|
|
|
{ kPanelDivId, kPanelBtn1Id, "myBtn1Id" },
|
|
|
|
{ kPanelDivId, kPanelCheck1Id, "myCheck1Id" },
|
|
|
|
{ kPanelDivId, kPanelBtn2Id, "myBtn2Id" },
|
|
|
|
{ kPanelDivId, kPanelCheck2Id, "myCheck2Id" },
|
|
|
|
{ kPanelDivId, kPanelFloaterId, "myFloater" },
|
|
|
|
{ kPanelDivId, kSelId, "mySel" },
|
|
|
|
{ kSelId, kOpt1Id, "myOpt1" },
|
|
|
|
{ kSelId, kOpt2Id, "myOpt2" },
|
|
|
|
{ kSelId, kOpt3Id, "myOpt3" },
|
2021-11-01 14:11:27 +00:00
|
|
|
{ kPanelDivId, kListId, "myListId" }
|
|
|
|
|
2020-04-27 12:14:26 +00:00
|
|
|
};
|
2020-04-24 14:20:25 +00:00
|
|
|
|
2020-04-27 12:14:26 +00:00
|
|
|
unsigned mapN = sizeof(mapA)/sizeof(mapA[0]);
|
2021-01-20 18:10:56 +00:00
|
|
|
ui_test_t* app = mem::allocZ<ui_test_t>();
|
|
|
|
|
|
|
|
if( cfg == nullptr )
|
|
|
|
{
|
|
|
|
cwLogError(kInvalidArgRC,"ui::test() was not passed a valid cfg. object.");
|
|
|
|
goto errLabel;
|
|
|
|
}
|
|
|
|
|
|
|
|
if((rc = parseArgs(*cfg, args )) != kOkRC )
|
|
|
|
{
|
|
|
|
cwLogError(rc,"UI parse args failed in ui::test()");
|
|
|
|
goto errLabel;
|
|
|
|
}
|
|
|
|
|
|
|
|
app->quitFl.store(false);
|
|
|
|
|
|
|
|
// Initial values for the test applications
|
2020-04-24 14:20:25 +00:00
|
|
|
app->appCheckFl = true;
|
2020-04-28 12:42:16 +00:00
|
|
|
app->appSelOptAppId = kOption1Id;
|
2020-04-24 14:20:25 +00:00
|
|
|
app->appInteger = 5;
|
|
|
|
app->appFloat = 2.56;
|
|
|
|
app->appProgress = 7;
|
|
|
|
app->appString = mem::duplStr("fooz");
|
2020-04-28 12:42:16 +00:00
|
|
|
app->appCheck1Fl = false;
|
|
|
|
app->appCheck2Fl = true;
|
|
|
|
app->appNumb = 1.23;
|
|
|
|
app->appSelId = kOpt3Id;
|
2021-11-01 14:11:27 +00:00
|
|
|
|
|
|
|
if((rc = cfg->getv( "listEle", app->listEleCfg )) != kOkRC )
|
|
|
|
rc = cwLogError( rc, "The list element cfg. was not found.");
|
2020-04-24 14:20:25 +00:00
|
|
|
|
|
|
|
|
2021-01-20 18:10:56 +00:00
|
|
|
//app->uiCfgFn = "/home/kevin/src/cwtest/src/libcw/html/uiTest/ui.cfg";
|
2020-03-23 14:48:49 +00:00
|
|
|
|
2020-04-07 20:24:34 +00:00
|
|
|
// create the UI server
|
2021-01-20 18:10:56 +00:00
|
|
|
if((rc = srv::create(app->wsUiSrvH, args, app, _uiTestCallback, mapA, mapN, nullptr )) != kOkRC )
|
2020-04-07 20:24:34 +00:00
|
|
|
return rc;
|
|
|
|
|
|
|
|
|
|
|
|
// start the UI server
|
|
|
|
if((rc = srv::start(app->wsUiSrvH)) != kOkRC )
|
2020-03-23 14:48:49 +00:00
|
|
|
goto errLabel;
|
|
|
|
|
|
|
|
|
|
|
|
printf("'quit' to exit\n");
|
|
|
|
|
|
|
|
// readline loop
|
2020-04-28 12:42:16 +00:00
|
|
|
while( !app->quitFl.load() )
|
2020-03-23 14:48:49 +00:00
|
|
|
{
|
2020-04-28 12:42:16 +00:00
|
|
|
sleepMs(50);
|
2020-03-23 14:48:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
errLabel:
|
2021-01-20 18:10:56 +00:00
|
|
|
ui::ws::releaseArgs(args);
|
|
|
|
|
2020-03-23 14:48:49 +00:00
|
|
|
rc_t rc1 = kOkRC;
|
2020-04-07 20:24:34 +00:00
|
|
|
if( app->wsUiSrvH.isValid() )
|
|
|
|
rc1 = srv::destroy(app->wsUiSrvH);
|
2020-04-24 14:20:25 +00:00
|
|
|
|
|
|
|
mem::release(app->appString);
|
2020-04-07 20:24:34 +00:00
|
|
|
mem::release(app);
|
2020-03-23 14:48:49 +00:00
|
|
|
|
|
|
|
return rcSelect(rc,rc1);
|
|
|
|
}
|