本文整理汇总了C++中ArNetPacket::setLength方法的典型用法代码示例。如果您正苦于以下问题:C++ ArNetPacket::setLength方法的具体用法?C++ ArNetPacket::setLength怎么用?C++ ArNetPacket::setLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArNetPacket
的用法示例。
在下文中一共展示了ArNetPacket::setLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: netClientList
void ArCentralManager::netClientList(ArServerClient *client, ArNetPacket *packet)
{
ArNetPacket sendPacket;
std::list<ArCentralForwarder *>::iterator fIt;
ArCentralForwarder *forwarder;
ArTypes::UByte2 sizeLen;
ArTypes::UByte2 realLen;
unsigned int numConnected = 0;
myDataMutex.lock();
sizeLen = sendPacket.getLength();
sendPacket.uByte2ToBuf(0);
for (fIt = myForwarders.begin(); fIt != myForwarders.end(); fIt++)
{
forwarder = (*fIt);
if (!forwarder->isConnected())
continue;
numConnected++;
sendPacket.strToBuf("");
sendPacket.uByte2ToBuf(forwarder->getPort());
sendPacket.strToBuf(forwarder->getRobotName());
sendPacket.strToBuf("");
sendPacket.strToBuf(
forwarder->getClient()->getTcpSocket()->getIPString());
}
realLen = sendPacket.getLength();
sendPacket.setLength(sizeLen);
sendPacket.uByte2ToBuf(numConnected);
sendPacket.setLength(realLen);
myDataMutex.unlock();
client->sendPacketTcp(&sendPacket);
}
示例2: sendListPacket
void ArServerClient::sendListPacket(void)
{
ArNetPacket packet;
std::map<unsigned int, ArServerData *>::iterator it;
unsigned int count;
unsigned int shortLen;
unsigned int longLen;
ArServerData *serverData;
// First we send a list of numbers, names and descriptions
packet.setCommand(ArServerCommands::LIST);
// number of entries (we'll overwrite it later with the right number)
shortLen = packet.getLength();
packet.uByte2ToBuf(0);
// loop through the data to build the packet
for (it = myDataMap->begin(), count = 0; it != myDataMap->end(); it++)
{
serverData = (*it).second;
if (myUserInfo == NULL ||
serverData->getCommandGroup() == NULL ||
serverData->getCommandGroup()[0] == '\0' ||
myGroups.count(serverData->getCommandGroup()) != 0 ||
myGroups.count("all") != 0)
{
count++;
packet.uByte2ToBuf(serverData->getCommand());
packet.strToBuf(serverData->getName());
packet.strToBuf(serverData->getDescription());
}
}
// put the real number of entries in the right spot
longLen = packet.getLength();
packet.setLength(shortLen);
packet.uByte2ToBuf(count);
packet.setLength(longLen);
sendPacketTcp(&packet);
// then we send a list of the arguments and returns... they aren't
// combined so that the packet structure doesn't need to change
packet.empty();
packet.setCommand(ArServerCommands::LISTARGRET);
// number of entries (we'll overwrite it later with the right number)
shortLen = packet.getLength();
packet.uByte2ToBuf(0);
// loop through the data to build the packet
for (it = myDataMap->begin(), count = 0; it != myDataMap->end(); it++)
{
serverData = (*it).second;
if (myUserInfo == NULL ||
serverData->getCommandGroup() == NULL ||
serverData->getCommandGroup()[0] == '\0' ||
myGroups.count(serverData->getCommandGroup()) != 0 ||
myGroups.count("all") != 0)
{
count++;
packet.uByte2ToBuf(serverData->getCommand());
packet.strToBuf(serverData->getArgumentDescription());
packet.strToBuf(serverData->getReturnDescription());
}
}
// put the real number of entries in the right spot
longLen = packet.getLength();
packet.setLength(shortLen);
packet.uByte2ToBuf(count);
packet.setLength(longLen);
sendPacketTcp(&packet);
// then we send a list of command groups... they aren't
// combined so that the packet structure doesn't need to change
packet.empty();
packet.setCommand(ArServerCommands::LISTGROUPANDFLAGS);
// number of entries (we'll overwrite it later with the right number)
shortLen = packet.getLength();
packet.uByte2ToBuf(0);
// loop through the data to build the packet
for (it = myDataMap->begin(), count = 0; it != myDataMap->end(); it++)
{
serverData = (*it).second;
if (myUserInfo == NULL ||
serverData->getCommandGroup() == NULL ||
serverData->getCommandGroup()[0] == '\0' ||
myGroups.count(serverData->getCommandGroup()) != 0 ||
myGroups.count("all") != 0)
{
count++;
packet.uByte2ToBuf(serverData->getCommand());
packet.strToBuf(serverData->getCommandGroup());
packet.strToBuf(serverData->getDataFlagsString());
}
}
// put the real number of entries in the right spot
//.........这里部分代码省略.........