Пример #1
0
int main(int argc, char **argv)
{
  Aria::init();
  ArGlobalFunctor1<ArNetPacket *> clientListHandlerCB(&clientListHandler);
  ArGlobalFunctor1<ArNetPacket *> clientAddedHandlerCB(&clientAddedHandler);
  ArGlobalFunctor1<ArNetPacket *> clientRemovedHandlerCB(&clientRemovedHandler);
  ArNetPacket packet;

  ArClientBase client;

  ArArgumentParser parser(&argc, argv);

  ArClientSimpleConnector clientConnector(&parser);

  parser.loadDefaultArguments();

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

  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);
  } 

  printf("Connected to server.\n");

  client.addHandler("clientList", &clientListHandlerCB);
  client.requestOnce("clientList");
  client.addHandler("clientRemoved", &clientRemovedHandlerCB);
  client.request("clientRemoved", -1);
  client.addHandler("clientAdded", &clientAddedHandlerCB);
  client.request("clientAdded", -1);
  client.run();
  Aria::shutdown();
  return 0;
}
Пример #2
0
int main(int argc, char **argv)
{

  ArGlobalFunctor1<ArNetPacket *> getMapNameCB(handleGetMapName);
  ArGlobalFunctor1<ArNetPacket *> getMapCB(handleGetMap);

  Aria::init();
  //ArLog::init(ArLog::StdOut, ArLog::Verbose);

  ArArgumentParser parser(&argc, argv);
	
  ArClientSimpleConnector clientConnector(&parser);

  parser.loadDefaultArguments();

  /* Check for -help, and unhandled arguments: */
  if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
  {
    Aria::logOptions();
    exit(0);
  }
  /* Connect our client object to the remote server: */
  if (!clientConnector.connectClient(&client))
  {
    exit(1);
  } 

  client.addHandler("getMap", &getMapCB);
  client.addHandler("getMapName", &getMapNameCB);
  client.requestOnce("getMapName");
  start.setToNow();
  client.requestOnce("getMap");

  client.run();

}