本文整理汇总了C++中MessageChannel::read方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageChannel::read方法的具体用法?C++ MessageChannel::read怎么用?C++ MessageChannel::read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageChannel
的用法示例。
在下文中一共展示了MessageChannel::read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: threadMain
/**
* The entry point of the thread that handles the client connection.
*/
void threadMain(const weak_ptr<Client> self) {
vector<string> args;
try {
while (!this_thread::interruption_requested()) {
try {
if (!channel.read(args)) {
// Client closed connection.
break;
}
} catch (const SystemException &e) {
P_TRACE(2, "Exception in ApplicationPoolServer client thread during "
"reading of a message: " << e.what());
break;
}
P_TRACE(4, "Client " << this << ": received message: " <<
toString(args));
if (args[0] == "get" && args.size() == 7) {
processGet(args);
} else if (args[0] == "close" && args.size() == 2) {
processClose(args);
} else if (args[0] == "clear" && args.size() == 1) {
processClear(args);
} else if (args[0] == "setMaxIdleTime" && args.size() == 2) {
processSetMaxIdleTime(args);
} else if (args[0] == "setMax" && args.size() == 2) {
processSetMax(args);
} else if (args[0] == "getActive" && args.size() == 1) {
processGetActive(args);
} else if (args[0] == "getCount" && args.size() == 1) {
processGetCount(args);
} else if (args[0] == "setMaxPerApp" && args.size() == 2) {
processSetMaxPerApp(atoi(args[1]));
} else if (args[0] == "getSpawnServerPid" && args.size() == 1) {
processGetSpawnServerPid(args);
} else {
processUnknownMessage(args);
break;
}
args.clear();
}
} catch (const boost::thread_interrupted &) {
P_TRACE(2, "Client thread " << this << " interrupted.");
} catch (const exception &e) {
P_TRACE(2, "Uncaught exception in ApplicationPoolServer client thread:\n"
<< " message: " << toString(args) << "\n"
<< " exception: " << e.what());
}
mutex::scoped_lock l(server.lock);
ClientPtr myself(self.lock());
if (myself != NULL) {
server.clients.erase(myself);
}
}
示例2: receivePassword
string receivePassword() {
TRACE_POINT();
vector<string> args;
if (!feedbackChannel.read(args)) {
throw IOException("The watchdog unexpectedly closed the connection.");
}
if (args[0] != "request socket password" && args[0] != "message socket password") {
throw IOException("Unexpected input message '" + args[0] + "'");
}
return Base64::decode(args[1]);
}