From 1d37204a37b9ce58fa1ef67d4a209573e559c391 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Fri, 12 Sep 2014 16:57:37 -0700 Subject: Refactoring in progress... pardon our dust... --- node/NodeConfig.hpp | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'node/NodeConfig.hpp') diff --git a/node/NodeConfig.hpp b/node/NodeConfig.hpp index b9bc8f5f..d374eee6 100644 --- a/node/NodeConfig.hpp +++ b/node/NodeConfig.hpp @@ -36,8 +36,6 @@ #include #include -#include "IpcListener.hpp" -#include "IpcConnection.hpp" #include "SharedPtr.hpp" #include "Network.hpp" #include "Utils.hpp" @@ -104,6 +102,38 @@ public: return nwlist; } + /** + * Join a network or return existing network if already joined + * + * @param nwid Network ID to join + * @return New network instance + */ + inline SharedPtr join(uint64_t nwid) + { + Mutex::Lock _l(_networks_m); + SharedPtr &nw = _networks[nwid]; + if (nw) + return nw; + else return (nw = Network::newInstance(_r,this,nwid)); + } + + /** + * Leave a network + * + * @param nwid Network ID + * @return True if network was left, false if we were not a member of this network + */ + inline bool leave(uint64_t nwid) + { + Mutex::Lock _l(_networks_m); + std::map< uint64_t,SharedPtr >::iterator n(_networks.find(nwid)); + if (n != _networks.end()) { + n->second->destroy(); + _networks.erase(n); + return true; + } else return false; + } + /** * Perform cleanup and possibly persist saved state */ @@ -135,18 +165,22 @@ public: } private: + /* static void _CBcommandHandler(void *arg,IpcConnection *ipcc,IpcConnection::EventType event,const char *commandLine); void _doCommand(IpcConnection *ipcc,const char *commandLine); + */ void _readLocalConfig(); void _writeLocalConfig(); const RuntimeEnvironment *_r; + /* IpcListener _ipcListener; std::string _authToken; std::map< IpcConnection *,bool > _connections; Mutex _connections_m; + */ Dictionary _localConfig; // persisted as local.conf Mutex _localConfig_m; -- cgit v1.2.3