Revision: 41627
          http://brlcad.svn.sourceforge.net/brlcad/?rev=41627&view=rev
Author:   davidloman
Date:     2010-12-15 18:21:33 +0000 (Wed, 15 Dec 2010)

Log Message:
-----------
Slew of test client updates

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-12-15 18:16:42 UTC (rev 41626)
+++ rt^3/trunk/src/GS/geoclient.cxx     2010-12-15 18:21:33 UTC (rev 41627)
@@ -54,7 +54,8 @@
 /**
  * Prints the 'usage' statement to the console along with an optional message
  */
-void printUsage(std::string customMsg) {
+void
+printUsage(std::string customMsg) {
        if (customMsg.length() > 0) {
                customMsg += "\n";
                QString s(customMsg.c_str());
@@ -65,7 +66,46 @@
        return;
 }
 
-void processIn(std::string in) {
+void
+handleSendShutdown(QString host, quint16 port, QString uname, QString passwd) {
+
+       /* Log */
+       QString s("Trying to connect to ");
+       s.append(host);
+       s.append(":");
+       s.append(QString::number(port));
+       logInfo(s);
+
+       PortalManager pm;
+       pm.start();
+       Portal* p = pm.connectToHost(host, port);
+       GSThread::msleep(250);
+
+       if (p == NULL){
+               pm.shutdown();
+               logInfo("Connection failed.");
+               return;
+       }
+
+       /* Authenticate */
+       /* TODO Make session AUTH */
+
+       NewSessionReqMsg nsrm(uname, passwd);
+       p->send(&nsrm);
+       GSThread::msleep(1250);
+
+       //Send Shutdown
+       TypeOnlyMsg tom(CMD_SHUTDOWN);
+       p->sendThenDisconnect(&tom);
+       GSThread::msleep(250);
+       pm.shutdown();
+
+       delete p;
+}
+
+
+void
+processIn(std::string in) {
        QString qin(in.c_str());
 
        //convert to lowercase
@@ -84,46 +124,38 @@
                stayRun = false;
                return;
        }
-    if(cmd == "sendshutdown") {
-       if (list.size() !=2 ) {
-               logInfo("useage: sendshutdown ip port");
-               return;
-       }
 
-       QString host = list.at(0);
-       quint16 port = atoi(list.at(1).toStdString().c_str());
+    if (cmd == "test01") {
+       processIn("sendshutdown localhost 5309 guest guest");
+       return;
+    }
 
-       //Log
-               QString s("Trying to connect to ");
-               s.append(host);
-               s.append(":");
-               s.append(list.at(1));
-               logInfo(s);
+    if (cmd == "test02") {
+       processIn("sendshutdown localhost 5309 g g");
+       return;
+    }
 
-       PortalManager pm;
-       pm.start();
-       Portal* p = pm.connectToHost(host, port);
-               GSThread::sleep(1);
+    if(cmd == "sendshutdown") {
+       if (list.size() !=4 ) {
+               logInfo("useage: sendshutdown ip port uname passwd");
+               return;
+       }
 
-               if (p == NULL){
-                       pm.shutdown();
-                       logInfo("Connection failed.");
-                       return;
-               }
+       QString host = list.at(0);
+       quint16 port = atoi(list.at(1).toStdString().c_str());
+       QString uname = list.at(2);
+       QString passwd = list.at(3);
 
-               //Authenticate
-               //TODO Make session AUTH
+       if (port <=0 || host.length() == 0 || uname.length() == 0 || 
passwd.length() == 0){
+               logInfo("useage: sendshutdown ip port uname passwd");
+               return;
+       }
 
-               //Send Shutdown
-               TypeOnlyMsg* tom = new TypeOnlyMsg(CMD_SHUTDOWN);
-               p->send(tom);
-               GSThread::sleep(1);
-               p->disconnect();
-               pm.shutdown();
+       handleSendShutdown(host, port, uname, passwd);
+               return;
+     }
 
-               delete p;
-               return;
-    }
+       logInfo("\tunknown command: '" + cmd + "'");
 }
 
 /*
@@ -134,7 +166,8 @@
  * =====================
  */
 
-int main(int argc, char* argv[])
+int
+main(int argc, char* argv[])
 {
        Logger::getInstance();
        JobManager::getInstance()->startup();


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to