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