当前位置: 首页>>代码示例>>C++>>正文


C++ ArNetPacket::uByte4ToBuf方法代码示例

本文整理汇总了C++中ArNetPacket::uByte4ToBuf方法的典型用法代码示例。如果您正苦于以下问题:C++ ArNetPacket::uByte4ToBuf方法的具体用法?C++ ArNetPacket::uByte4ToBuf怎么用?C++ ArNetPacket::uByte4ToBuf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArNetPacket的用法示例。


在下文中一共展示了ArNetPacket::uByte4ToBuf方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char **argv)
{
  Aria::init();
  //ArLog::init(ArLog::StdOut, ArLog::Verbose);
  ArClientBase client;

  ArArgumentParser parser(&argc, argv);

  ArClientSimpleConnector clientConnector(&parser);
  parser.loadDefaultArguments();

  if (!clientConnector.parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    clientConnector.logOptions();
    exit(0);
  }

  if (parser.getArgc() < 4 || parser.getArgc() > 6)
  {
    printf("usage: %s <x> <y> <th> <optional:xyspread> <optional:thspread>", argv[0]);
    exit(1);
  }

  if (!clientConnector.connectClient(&client))
  {
    if (client.wasRejected())
      printf("Server '%s' rejected connection, exiting\n", client.getHost());
    else
      printf("Could not connect to server '%s', exiting\n", client.getHost());
    exit(1);
  } 
  client.runAsync();

  ArNetPacket sending;
  // put in the arguments (you can see what they are from doing -lcl on clientDemo)
  sending.byte4ToBuf(atoi(parser.getArg(1)));
  sending.byte4ToBuf(atoi(parser.getArg(2)));
  sending.byte4ToBuf(atoi(parser.getArg(3)));
  if (parser.getArgc() > 4)
    sending.uByte4ToBuf(atoi(parser.getArg(4)));
  if (parser.getArgc() > 5)
    sending.uByte4ToBuf(atoi(parser.getArg(5)));
  // send the packet
  client.requestOnce("localizeToPose", &sending);

  // you have to give the client some time to send the command
  ArUtil::sleep(500);
  

  Aria::shutdown();
  return 0;
}
开发者ID:sauver,项目名称:sauver_sys,代码行数:52,代码来源:clientLocalizeToPose.cpp

示例2: netGetDrawingList

AREXPORT void ArServerInfoDrawings::netGetDrawingList(ArServerClient *client, 
						    ArNetPacket *packet)
{
  ArNetPacket sendingPacket;
  
  // TODO: Any need to protect the map by a mutex?

  for (std::map<std::string, ArDrawingData *, ArStrCaseCmpOp>::iterator it = 
                myDrawingDatas.begin(); 
       it != myDrawingDatas.end(); 
       it++)
  {
    sendingPacket.empty();

    sendingPacket.strToBuf((*it).first.c_str());
    sendingPacket.strToBuf((*it).second->getShape());
    sendingPacket.byte4ToBuf((*it).second->getPrimaryColor().colorToByte4());
    sendingPacket.byte4ToBuf((*it).second->getSize());
    sendingPacket.byte4ToBuf((*it).second->getLayer());
    sendingPacket.uByte4ToBuf((*it).second->getDefaultRefreshTime());
    sendingPacket.byte4ToBuf((*it).second->getSecondaryColor().colorToByte4());
    sendingPacket.strToBuf((*it).second->getVisibility());

    client->sendPacketTcp(&sendingPacket);

  } // end for each drawing

  sendingPacket.empty();
  client->sendPacketTcp(&sendingPacket);
}
开发者ID:YGskty,项目名称:avoid_side_Aria,代码行数:30,代码来源:ArServerInfoDrawings.cpp

示例3:

AREXPORT void ArServerHandlerCommMonitor::handleGetHeartbeatInterval
                                              (ArServerClient *client, 
                                               ArNetPacket *packet)
{
  if (client == NULL) {
    return; // Something very bad has happened...
  }

  ArNetPacket sendPacket;
  sendPacket.uByte4ToBuf(myHeartbeatInterval);

  client->sendPacketTcp(&sendPacket);

} // end method handleGetHeartbeatInterval
开发者ID:PipFall2015,项目名称:Ottos-Cloud,代码行数:14,代码来源:ArServerHandlerCommMonitor.cpp

示例4: netListDrawings

AREXPORT void ArServerInfoDrawings::netListDrawings(ArServerClient *client, 
						    ArNetPacket *packet)
{
  ArNetPacket sendingPacket;
  std::map<std::string, ArDrawingData *, ArStrCaseCmpOp>::iterator it;
  
  sendingPacket.byte4ToBuf(myDrawingDatas.size());
  for (it = myDrawingDatas.begin(); it != myDrawingDatas.end(); it++)
  {
    sendingPacket.strToBuf((*it).first.c_str());
    sendingPacket.strToBuf((*it).second->getShape());
    sendingPacket.byte4ToBuf((*it).second->getPrimaryColor().colorToByte4());
    sendingPacket.byte4ToBuf((*it).second->getSize());
    sendingPacket.byte4ToBuf((*it).second->getLayer());
    sendingPacket.uByte4ToBuf((*it).second->getDefaultRefreshTime());
    sendingPacket.byte4ToBuf((*it).second->getSecondaryColor().colorToByte4());
  }
  client->sendPacketTcp(&sendingPacket);
}
开发者ID:YGskty,项目名称:avoid_side_Aria,代码行数:19,代码来源:ArServerInfoDrawings.cpp

示例5: ArServerClient

AREXPORT ArServerClient::ArServerClient(
	ArSocket *tcpSocket, unsigned int udpPort, long authKey,
	long introKey, 	ArRetFunctor2<bool, ArNetPacket *, 
	struct sockaddr_in *> *sendUdpCallback,
	std::map<unsigned int, ArServerData *> *dataMap,
	const char *passwordKey, const char *serverKey,
	const ArServerUserInfo *userInfo, int rejecting, 
	const char *rejectingString, bool debugLogging,
	const char *serverClientName, bool logPasswordFailureVerbosely,
	bool allowSlowPackets, bool allowIdlePackets) :
  myProcessPacketCB(this, &ArServerClient::processPacket, NULL, true)
{
  ArNetPacket packet;

  // set our default to no command
  pushCommand(0);

  myAuthKey = authKey;
  myIntroKey = introKey;
  myTcpSocket.transfer(tcpSocket);
  myTcpSocket.setCloseCallback(tcpSocket->getCloseCallback());
  myTcpSocket.setNonBlock();
  myTcpReceiver.setSocket(&myTcpSocket);
  myTcpReceiver.setProcessPacketCB(&myProcessPacketCB);
  myTcpSender.setSocket(&myTcpSocket);

  mySendUdpCB = sendUdpCallback;
  myDataMap = dataMap;
  if (udpPort == 0)
    myTcpOnly = true;
  else
    myTcpOnly = false;
  mySentTcpOnly = myTcpOnly;

  myUserInfo = userInfo;
  myPasswordKey = passwordKey;
  myServerKey = serverKey;
  myRejecting = rejecting;
  if (rejectingString != NULL)
    myRejectingString = rejectingString;

  myDebugLogging = debugLogging;
  if (myDebugLogging)
    myVerboseLogLevel = ArLog::Normal;
  else
    myVerboseLogLevel = ArLog::Verbose;

  myTcpSender.setDebugLogging(myDebugLogging);

  myLogPrefix = serverClientName;
  myLogPrefix += ": ";
  myTcpSender.setLoggingPrefix(myLogPrefix.c_str());
  myTcpReceiver.setLoggingPrefix(myLogPrefix.c_str());

  myLogPasswordFailureVerbosely = logPasswordFailureVerbosely;

  mySlowPacketsMutex.setLogName("ArServerClient::mySlowPacketsMutex");
  myIdlePacketsMutex.setLogName("ArServerClient::myIdlePacketsMutex");

  myAllowSlowPackets = allowSlowPackets;
  myAllowIdlePackets = allowIdlePackets;

  setIdentifier(ArServerClientIdentifier());
  internalSwitchState(STATE_SENT_INTRO);

  packet.empty();
  packet.setCommand(ArServerCommands::INTRODUCTION);
  packet.strToBuf("alpha");
  packet.uByte2ToBuf(udpPort);
  packet.uByte4ToBuf(myAuthKey);
  packet.uByte4ToBuf(myIntroKey);
  packet.strToBuf(myPasswordKey.c_str());
  sendPacketTcp(&packet);

  mySlowIdleThread = NULL;

  myHaveSlowPackets = false;
  myHaveIdlePackets = false;
  
  myCreationTime.setToNow();

  resetTracking();
}
开发者ID:sendtooscar,项目名称:ariaClientDriver,代码行数:83,代码来源:ArServerClient.cpp

示例6: putFile

void putFile(char *fileName, char *asFileName)
{
  ArNetPacket sendPacket;
  size_t ui;
  size_t len;

  FILE *file;
  if ((file = ArUtil::fopen(fileName, "r")) == NULL)
  {
    ArLog::log(ArLog::Normal, 
	       "putFile: can't open file '%s'", fileName);
    return;
  }

  // tell the server we're sending
  
  sendPacket.empty();
  sendPacket.uByte2ToBuf(0);
  sendPacket.strToBuf(asFileName);
  client.requestOnce("putFile", &sendPacket);
  printf("Starting send of file %s\n", fileName);
  
  char buf[30000];
  size_t ret;
  // now send the file
  while ((ret = fread(buf, 1, sizeof(buf), file)) == sizeof(buf))
  {
    sendPacket.empty();
    sendPacket.uByte2ToBuf(1);
    sendPacket.strToBuf(asFileName);
    sendPacket.uByte4ToBuf(ret);
    sendPacket.dataToBuf(buf, ret);
    client.requestOnce("putFile", &sendPacket);
    printf("Sent packet with %d\n", ret);
  }
  if (ferror(file))
  {
    ArLog::log(ArLog::Normal, "ArServerFileToClient: Error sending file %s", 
	       fileName);
    sendPacket.empty();
    sendPacket.uByte2ToBuf(3);
    sendPacket.strToBuf(asFileName);
    client.requestOnce("putFile", &sendPacket);
    return;
  }

  sendPacket.empty();
  sendPacket.uByte2ToBuf(1);
  sendPacket.strToBuf(asFileName);
  sendPacket.uByte4ToBuf(ret);
  sendPacket.dataToBuf(buf, ret);
  client.requestOnce("putFile", &sendPacket);
  printf("Sent packet with %d\n", ret);


  sendPacket.empty();
  sendPacket.uByte2ToBuf(2);
  sendPacket.strToBuf(asFileName);
  client.requestOnce("putFile", &sendPacket);

  if (feof(file))
  {
    ArLog::log(ArLog::Normal, "ArServerFileToClient: Sent file %s", fileName);
  }
  
  fclose(file);
}
开发者ID:sauver,项目名称:sauver_sys,代码行数:67,代码来源:fileClientRaw.cpp


注:本文中的ArNetPacket::uByte4ToBuf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。