From 347a446116244bf67bb132c10bb3b3ad6810d53c Mon Sep 17 00:00:00 2001 From: Evgeny Gagua Date: Tue, 17 Mar 2026 03:11:33 +0200 Subject: [PATCH] Prev. attempt to fix was changed to Delay Connection to Remode Server untill Nodes are in Pending Load State --- lib/App/common/deviceNodeFactory.h | 1 + lib/App/mojo/mojoKernel.cpp | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/App/common/deviceNodeFactory.h b/lib/App/common/deviceNodeFactory.h index 9d5cf47f..2a375088 100644 --- a/lib/App/common/deviceNodeFactory.h +++ b/lib/App/common/deviceNodeFactory.h @@ -25,6 +25,7 @@ class deviceNodeFactory: public basicThread{ deviceNode * getNode( uint32_t id ); uint32_t getNodesCount( ARGUS_NODE_TYPE type ); bool loadNodes(); + bool nodesAreLoaded(){ return m_vDeviceNodes.size()>0; }; bool unloadNodes( void ); bool reloadNodes( ); bool reloadNode( uint32_t NodeID ); diff --git a/lib/App/mojo/mojoKernel.cpp b/lib/App/mojo/mojoKernel.cpp index a85f8a8e..e91f3ba6 100644 --- a/lib/App/mojo/mojoKernel.cpp +++ b/lib/App/mojo/mojoKernel.cpp @@ -229,7 +229,8 @@ bool mojoKernel::create(){ m_bDebugMode = m_pDBC->getAppDebugMode(); if ( m_bDebugMode ) m_bKeepLocalReport = true; //Forced in case of debug mode - m_bWorkWithRemoteServer = m_sSiteData.use_remote_server; + /// m_bWorkWithRemoteServer = m_sSiteData.use_remote_server; -> + /// since Connection is delayed - must be not set at beginning //Check date/Time if correct! // Just in case that we have local reports @@ -288,8 +289,8 @@ bool mojoKernel::create(){ return false; }; - m_pNodeFactory->loadNodes(); - + // Must Be moved elsewhere To be connected after all Nodes are Loadded ?? at Node's Validation ?? + /* if ( m_bWorkWithRemoteServer ) { #ifdef DEBUG LOG("Working With Remote Server"); @@ -300,7 +301,7 @@ bool mojoKernel::create(){ } else LOG_ERROR("Cannot Connect to Remote Server!"); } else m_bWorkWithRemoteServer = false; }; - + */ return init(); }; @@ -540,6 +541,16 @@ void mojoKernel::m_fThreadProc( void ){ if( m_pRPC ){ m_pRPC->validate(); m_bWorkWithRemoteServer = ( m_pRPC->getConnectionStatus() == CS_CONNECTED ); + } else { + //Checking if Nodes are Loadded + if( m_pNodeFactory->nodesAreLoaded() ){ +#ifdef DEBUG + LOG("Initial Connect to Remote Server"); +#endif + if ( m_pRPC = new mojoRemoteClient( this ) ) { + if( !( m_bWorkWithRemoteServer = m_pRPC->create() ) ) LOG_ERROR("Cannot Connect to Remote Server!"); + } else m_bWorkWithRemoteServer = false; + }; }; }; DBC_PUSHED_CMD * tCMD = m_pDBC->getNodePushedCMD( m_nServerNodeID ); //Kernel