Revision: 40838
http://brlcad.svn.sourceforge.net/brlcad/?rev=40838&view=rev
Author: davidloman
Date: 2010-09-29 16:33:06 +0000 (Wed, 29 Sep 2010)
Log Message:
-----------
Wire in basic framework for sending a shutdown message from geoclient.
Modified Paths:
--------------
rt^3/trunk/src/GS/geoclient.cxx
Modified: rt^3/trunk/src/GS/geoclient.cxx
===================================================================
--- rt^3/trunk/src/GS/geoclient.cxx 2010-09-29 16:27:12 UTC (rev 40837)
+++ rt^3/trunk/src/GS/geoclient.cxx 2010-09-29 16:33:06 UTC (rev 40838)
@@ -25,17 +25,133 @@
#include "GeometryService.h"
+#include "libjob.h"
#include "libutility.h"
#include "libevent.h"
+#include "libnet.h"
+#include <string>
#include <iostream>
#include <stdlib.h>
#include <QtCore/QString>
+#include <QtCore/QStringList>
+
+bool stayRun = true;
+std::string prompt ="geoclient> ";
+
+void logInfo(QString s) {
+ Logger::getInstance()->logINFO("geoclient", s);
+}
+void logBanner(QString s) {
+ Logger::getInstance()->logBANNER("geoclient", s);
+}
+
+/**
+ * Prints the 'usage' statement to the console along with an optional message
+ */
+void printUsage(std::string customMsg) {
+
+ if (customMsg.length() > 0) {
+ customMsg += "\n";
+ QString s(customMsg.c_str());
+ logInfo(s);
+ }
+ logInfo("Usage: geoclient\n");
+
+ return;
+}
+
+void processIn(std::string in) {
+ QString qin(in.c_str());
+
+ //convert to lowercase
+ qin = qin.toLower();
+
+ //split string
+ QStringList list = qin.split(" ");
+
+ //check to see if there is at least one element
+ if (list.length() <= 0) {
+ return;
+ }
+ QString cmd = list.takeAt(0);
+
+ if (cmd == "exit" || cmd == "quit") {
+ stayRun = false;
+ return;
+ }
+ if(cmd == "sendshutdown") {
+ std::cout << list.size() << std::endl;
+ if (list.size() !=2 ) {
+ logInfo("useage: sendshutdown ip port");
+ return;
+ }
+
+ QString host = list.at(0);
+ quint16 port = atoi(list.at(1).toStdString().c_str());
+
+ //Log
+ QString s("Trying to connect to ");
+ s.append(host);
+ s.append(":");
+ s.append(list.at(1));
+ logInfo(s);
+
+ PortalManager pm;
+ pm.start();
+ Portal* p = pm.connectToHost(host, port);
+ GSThread::sleep(1);
+
+ if (p == NULL){
+ pm.shutdown();
+ logInfo("Connection failed.");
+ return;
+ }
+
+ //Authenticate
+
+ //Send Shutdown
+ TypeOnlyMsg* tom = new TypeOnlyMsg(CMD_SHUTDOWN);
+ p->send(tom);
+ GSThread::sleep(1);
+ p->disconnect();
+ pm.shutdown();
+
+ delete p;
+ return;
+ }
+
+}
+
+/*
+ * =====================
+ *
+ * Main
+ *
+ * =====================
+ */
+
+
int main(int argc, char* argv[])
{
+ Logger::getInstance();
+ JobManager::getInstance()->startup();
+ logBanner("==================================");
+ logBanner("GeometryService Test/Stress Client");
+ logBanner("==================================");
+ std::string in;
+ while (stayRun) {
+ in == "";
+ std::cout << prompt;
+ getline (std::cin, in);
+
+ processIn(in);
+ }
+
+ logInfo("Exiting.");
return 0;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits