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


C++ ArClientBase::blockingConnect方法代码示例

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


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

示例1: main

int main(int argc, char **argv)
{
  char* host = "localhost";
  if(argc > 1)
    host = argv[1];
  Aria::init();
  ArClientBase client;
  ArGlobalFunctor escapeCB(&escape);
  ArKeyHandler keyHandler;
  Aria::setKeyHandler(&keyHandler);


  printf("Connecting to standaloneServerDemo at %s:%d...\n", host, 7272);
  if (!client.blockingConnect(host, 7272))
  {
    printf("Could not connect to server, exiting\n");
    exit(1);
  } 
  InputHandler inputHandler(&client, &keyHandler);
  OutputHandler outputHandler(&client);
  keyHandler.addKeyHandler(ArKeyHandler::ESCAPE, &escapeCB);
  client.runAsync();
  while (client.getRunningWithLock())
  {
    keyHandler.checkKeys();
    ArUtil::sleep(1);
  }
  keyHandler.restore();
  Aria::shutdown();
  return 0;
}
开发者ID:sendtooscar,项目名称:ariaClientDriver,代码行数:31,代码来源:standaloneClientDemo.cpp

示例2: main

int main(int argc, char **argv)
{

  std::string hostname;
  Aria::init();
  //ArLog::init(ArLog::StdOut, ArLog::Verbose);

  if (argc == 1)
    hostname = "localhost";
  else
    hostname = argv[1];
  if (!client.blockingConnect(hostname.c_str(), 7272))
  {
    printf("Could not connect to server, exiting\n");
    exit(1);
  } 

  
  /*
  ArGlobalFunctor1<ArNetPacket *> getDirListingCB(&getDirListing);
  client.addHandler("getDirListing", &getDirListingCB);
  //client.requestOnceWithString("getDirListing", "");

  ArGlobalFunctor1<ArNetPacket *> getFileCB(&netGetFile);
  client.addHandler("getFile", &getFileCB);
  client.requestOnceWithString("getFile", "all.bob");

  ArGlobalFunctor1<ArNetPacket *> netPutFileCB(&netPutFile);
  client.addHandler("putFile", &netPutFileCB);
  putFile("doxygen.conf", "ArGH/DoxYGEN");
  */

  ArGlobalFunctor1<ArNetPacket *> deleteFileCB(&netDeleteFile);
  client.addHandler("deleteFile", &deleteFileCB);
  client.requestOnceWithString("deleteFile", "1/all.bob");

  client.runAsync();

  while (client.getRunningWithLock())
  {
    ArUtil::sleep(1);
  }
  Aria::shutdown();
  return 0;

}
开发者ID:sauver,项目名称:sauver_sys,代码行数:46,代码来源:fileClientRaw.cpp

示例3: main

int main(int argc, char **argv)
{
  ArClientBase client;
  ArGlobalFunctor1<ArNetPacket *> testCB(&test);

  Aria::init();
  //ArLog::init(ArLog::StdOut, ArLog::Verbose);
  ArTime startTime;
  startTime.setToNow();
  if (!client.blockingConnect("localhost", 7273))
  {
    printf("Could not connect to server, exiting\n");
    exit(1);
  }    
  printf("Took %ld msec to connect\n", startTime.mSecSince());
  
  client.runAsync();
  
  client.lock();
  client.addHandler("test", &testCB);
  client.addHandler("test2", &testCB);
  client.addHandler("test3", &testCB);
  client.logDataList();
  
  client.requestOnce("test");
  client.request("test2", 100);
  client.request("test3", -1);
  client.unlock();
  ArUtil::sleep(1000);
  printf("Changing speed\n");
  client.lock();
  client.request("test2", 300);
  client.unlock();
  ArUtil::sleep(1000);
  client.lock();
  client.requestStop("test2");
  client.unlock();
  
  ArUtil::sleep(1000);
  client.lock();
  client.disconnect();
  client.unlock();
  ArUtil::sleep(50);
  exit(0);
}
开发者ID:sanyaade-research-hub,项目名称:aria,代码行数:45,代码来源:testClient.cpp

示例4: OutputHandler

/** 
 Initialize the robot connection 
*/
JNIEXPORT jint JNICALL Java_com_adept_arandroid_ArjRobot_initialize
  (JNIEnv *env, jobject obj, jstring host, jint port)
{
	// Get the host ip address
	const char *cHost = env->GetStringUTFChars(host, 0);
	
	// Try to connect
	Aria::init();
  ArLog::setFunctor(new ArGlobalFunctor1<const char*>(ariaLogDebugPrint));
	debugPrintS("Connecting to ", cHost);
	if (!myClient.blockingConnect(cHost, port, true, NULL, NULL, NULL)) {
		debugPrint("Error connecting");
		return -1;
	}
	debugPrint("Connected");
	
	// Run the client connection in a different thread  
	myClient.runAsync();
	
	// Download the map, maybe move this to it's own function later
	debugPrint("getting map");
	myClient.requestOnce("getMapBinary");
	
	// Create the OutputHandler
	myOutputHandler = new OutputHandler(&myClient);
	
	/* Block until the connection is closed.  We will use this time to get
	 * status update information at a regular rate. */
	myShutdown = false;
	while (myClient.getRunningWithLock() && !myShutdown) {
    ArUtil::sleep(100);
    myServerStatus = myOutputHandler->getServerStatus();
    myOutputHandler->getRobotStatus(myRobotStatus);
  }
  debugPrint("Shutting down Aria");
  myClient.disconnect();
  Aria::shutdown();
  return 0;
}
开发者ID:Aharobot,项目名称:ArAndroidApp,代码行数:42,代码来源:native_ArjRobot.cpp


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