diff --git a/src/code_generator.cpp b/src/code_generator.cpp index 0f078af..8467df7 100644 --- a/src/code_generator.cpp +++ b/src/code_generator.cpp @@ -60,6 +60,7 @@ void CodeGenerator::createFile(const string &file, const bool bEntry) if (_bClient) { + addTarsPingForProxy(contexts[i]); // add tars_ping function for client proxy if (_bTS) { if (!generateTSProxy(contexts[i])) return; // generate .ts for proxy classes @@ -107,3 +108,16 @@ void CodeGenerator::createFile(const string &file, const bool bEntry) } } } + +void CodeGenerator::addTarsPingForProxy(const ContextPtr &cPtr){ + vector namespaces = cPtr->getNamespaces(); + string ping = TC_Common::lower(IDL_NAMESPACE_STR) + "_ping"; + for(size_t i = 0; i < namespaces.size(); i++) + { + vector & is = namespaces[i]->getAllInterfacePtr(); + for (size_t ii = 0; ii < is.size(); ii++) + { + is[ii]->createOperation(ping, nullptr); + } + } +} diff --git a/src/code_generator.h b/src/code_generator.h index 3d90486..7eb7353 100644 --- a/src/code_generator.h +++ b/src/code_generator.h @@ -150,6 +150,8 @@ private: void scan(const string & sFile, bool bNotPrefix); + void addTarsPingForProxy(const ContextPtr &cPtr); + string makeName(); string findName(const string & sNamespace, const string & sName, const bool &bBase = false);