Thread: [brlcad-commits] SF.net SVN: brlcad:[40838] rt^3/trunk/src/GS/geoclient.cxx
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <dav...@us...> - 2010-09-29 16:33:13
|
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. |
From: <dav...@us...> - 2010-12-15 18:21:40
|
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. |
From: <dav...@us...> - 2010-12-16 19:03:59
|
Revision: 41670 http://brlcad.svn.sourceforge.net/brlcad/?rev=41670&view=rev Author: davidloman Date: 2010-12-16 19:03:53 +0000 (Thu, 16 Dec 2010) Log Message: ----------- Remove a bunch of antiquated code. New Cmd handler system handles all this now. 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-16 19:03:21 UTC (rev 41669) +++ rt^3/trunk/src/GS/geoclient.cxx 2010-12-16 19:03:53 UTC (rev 41670) @@ -23,177 +23,21 @@ * */ -#include "GeometryService.h" -#include "libjob.h" -#include "libutility.h" -#include "libevent.h" -#include "libnet.h" +#include "GSClient.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 -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 - 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 == "test01") { - processIn("sendshutdown localhost 5309 guest guest"); - return; - } - - if (cmd == "test02") { - processIn("sendshutdown localhost 5309 g g"); - return; - } - - if(cmd == "sendshutdown") { - if (list.size() !=4 ) { - logInfo("useage: sendshutdown ip port uname passwd"); - 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); - - if (port <=0 || host.length() == 0 || uname.length() == 0 || passwd.length() == 0){ - logInfo("useage: sendshutdown ip port uname passwd"); - return; - } - - handleSendShutdown(host, port, uname, passwd); - return; - } - - logInfo("\tunknown command: '" + cmd + "'"); -} - -/* - * ===================== - * - * 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; + GSClient gsClient; + return gsClient.run(); } -// Local Variables: -// tab-width: 8 -// mode: C++ -// c-basic-offset: 4 -// indent-tabs-mode: t -// c-file-style: "stroustrup" -// End: -// ex: shiftwidth=4 tabstop=8 +/* + * Local Variables: + * tab-width: 8 + * mode: C + * indent-tabs-mode: t + * c-file-style: "stroustrup" + * End: + * ex: shiftwidth=4 tabstop=8 + */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |