本文整理汇总了C++中ArNetPacket::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ ArNetPacket::isValid方法的具体用法?C++ ArNetPacket::isValid怎么用?C++ ArNetPacket::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArNetPacket
的用法示例。
在下文中一共展示了ArNetPacket::isValid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleGetConfig
/**
* @param client the ArServerClient * to which to send the config
* @param packet the ArNetPacket * which accompanied the client's request
* @param isMultiplePackets a bool set to true if the server should send a
* packet for each config section followed by the empty packet; false if
* the server should send the entire config in one packet (i.e. the old style)
* @param lastPriority the last ArPriority::Priority that should be sent
* to the client (this is the greatest numerical value and the least
* semantic priority).
**/
AREXPORT void ArServerHandlerConfig::handleGetConfig(ArServerClient *client,
ArNetPacket *packet,
bool isMultiplePackets,
ArPriority::Priority lastPriority)
{
ArConfigArg param;
// The multiple packets method also sends display hints with the parameters;
// the old single packet method does not.
ArClientArg clientArg(isMultiplePackets,
lastPriority);
std::set<std::string> sent;
ArNetPacket sending;
ArLog::log(ArLog::Normal, "Config requested.");
std::list<ArConfigSection *> *sections = myConfig->getSections();
for (std::list<ArConfigSection *>::iterator sIt = sections->begin();
sIt != sections->end();
sIt++)
{
// Clear the packet...
if (isMultiplePackets) {
sending.empty();
}
// clear out the sent list between sections
sent.clear();
ArConfigSection *section = (*sIt);
if (section == NULL) {
continue;
}
sending.byteToBuf('S');
sending.strToBuf(section->getName());
sending.strToBuf(section->getComment());
ArLog::log(ArLog::Verbose, "Sending config section %s...", section->getName());
//printf("S %s %s\n", section->getName(), section->getComment());
std::list<ArConfigArg> *params = section->getParams();
for (std::list<ArConfigArg>::iterator pIt = params->begin();
pIt != params->end();
pIt++)
{
param = (*pIt);
bool isCheckableName =
(param.getType() != ArConfigArg::DESCRIPTION_HOLDER &&
param.getType() != ArConfigArg::SEPARATOR &&
param.getType() != ArConfigArg::STRING_HOLDER);
// if we've already sent it don't send it again
if (isCheckableName &&
sent.find(param.getName()) != sent.end()) {
continue;
}
else if (isCheckableName) {
sent.insert(param.getName());
}
if (clientArg.isSendableParamType(param))
{
sending.byteToBuf('P');
bool isSuccess = clientArg.createPacket(param,
&sending);
}
} // end for each parameter
if (!sending.isValid()) {
ArLog::log(ArLog::Terse, "Config section %s cannot be sent; packet size exceeded",
section->getName());
} // end if length exceeded...
else if (isMultiplePackets) {
client->sendPacketTcp(&sending);
} // end else send in chunks...
} // end for each section
// If sending each section in individual packets, then send an empty packet
//.........这里部分代码省略.........