Merge pull request #7 from zouchengzhuo/master

add ping for client proxy
This commit is contained in:
ruanshudong 2022-05-20 22:08:03 +08:00 committed by GitHub
commit ea4e5f7109
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View File

@ -60,6 +60,7 @@ void CodeGenerator::createFile(const string &file, const bool bEntry)
if (_bClient) if (_bClient)
{ {
addTarsPingForProxy(contexts[i]); // add tars_ping function for client proxy
if (_bTS) if (_bTS)
{ {
if (!generateTSProxy(contexts[i])) return; // generate .ts for proxy classes 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<NamespacePtr> namespaces = cPtr->getNamespaces();
string ping = TC_Common::lower(IDL_NAMESPACE_STR) + "_ping";
for(size_t i = 0; i < namespaces.size(); i++)
{
vector<InterfacePtr> & is = namespaces[i]->getAllInterfacePtr();
for (size_t ii = 0; ii < is.size(); ii++)
{
is[ii]->createOperation(ping, nullptr);
}
}
}

View File

@ -150,6 +150,8 @@ private:
void scan(const string & sFile, bool bNotPrefix); void scan(const string & sFile, bool bNotPrefix);
void addTarsPingForProxy(const ContextPtr &cPtr);
string makeName(); string makeName();
string findName(const string & sNamespace, const string & sName, const bool &bBase = false); string findName(const string & sNamespace, const string & sName, const bool &bBase = false);