本文整理汇总了C++中ObjectRef::Process方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectRef::Process方法的具体用法?C++ ObjectRef::Process怎么用?C++ ObjectRef::Process使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectRef
的用法示例。
在下文中一共展示了ObjectRef::Process方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: svc
int CommandLineServer::svc(void)
{
for (bool active = true;active == true;)
{
char buf[2048];
ACE_Time_Value timeout;
timeout.sec(3600);
int i = 0;
// Display prompt
char prompt[] = "\r\n>";
peer().send(prompt, 3, MSG_NOSIGNAL);
// Get one command line
bool foundCRLF = false;
while(active && !foundCRLF && i<2040)
{
ssize_t size = peer().recv(buf+i, 2040-i, &timeout);
if (size == 0 || size == -1)
{
active = false;
}
else
{
for(int j=0; j<size && !foundCRLF;j++)
{
if(buf[i+j] == '\r' || buf[i+j] == '\n')
{
foundCRLF = true;
buf[i+j] = '\0';
CStdString command(buf);
try
{
CStdString className = SingleLineSerializer::FindClass(command);
ObjectRef objRef = ObjectFactory::GetSingleton()->NewInstance(className);
if (objRef.get())
{
objRef->DeSerializeSingleLine(command);
ObjectRef response = objRef->Process();
CStdString responseString = response->SerializeSingleLine();
peer().send((PCSTR)responseString, responseString.GetLength(), MSG_NOSIGNAL);
}
else
{
CStdString error = "Unrecognized command";
peer().send(error, error.GetLength(), MSG_NOSIGNAL); ;
}
}
catch (CStdString& e)
{
peer().send(e, e.GetLength(), MSG_NOSIGNAL); ;
}
}
}
i += size;
}
}
}
return 0;
}