Revision: 40579
http://brlcad.svn.sourceforge.net/brlcad/?rev=40579&view=rev
Author: davidloman
Date: 2010-09-15 16:26:19 +0000 (Wed, 15 Sep 2010)
Log Message:
-----------
Now that libPkgCpp is done. Rip out old networking code since its all going to
change.
Modified Paths:
--------------
rt^3/trunk/include/GeometryService.h
rt^3/trunk/include/NetPortal.h
rt^3/trunk/include/NetPortalManager.h
rt^3/trunk/src/GS/GeometryService.cxx
rt^3/trunk/src/GS/SessionManager.cxx
rt^3/trunk/src/GS/SessionManager.h
rt^3/trunk/src/GS/gsmain.cxx
rt^3/trunk/src/libNet/CMakeLists.txt
rt^3/trunk/src/libNet/NetPortal.cxx
rt^3/trunk/src/libNet/NetPortalManager.cxx
Removed Paths:
-------------
rt^3/trunk/include/Gateway.h
rt^3/trunk/src/libNet/Gateway.cxx
Deleted: rt^3/trunk/include/Gateway.h
===================================================================
--- rt^3/trunk/include/Gateway.h 2010-09-15 15:09:45 UTC (rev 40578)
+++ rt^3/trunk/include/Gateway.h 2010-09-15 16:26:19 UTC (rev 40579)
@@ -1,73 +0,0 @@
-/* G A T E W A Y . H
- * BRLCAD
- *
- * Copyright (c) 2010 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this file; see the file named COPYING for more
- * information.
- */
-/** @file Gateway.h
- *
- * Wraps up a NetPortalManager, a QThread and all supporting code to make a
simple to use, internally threaded Gateway.
- *
- */
-
-#ifndef __GATEWAY_H__
-#define __GATEWAY_H__
-
-#include "INetMsgHandler.h"
-
-#include "libutility.h"
-
-#include <QThread>
-#include <QString>
-#include <QHostAddress>
-#include <QList>
-
-class NetPortalManager;
-
-class Gateway: public QThread
-{
-public:
- Gateway(QString gsHostname, INetMsgHandler* handler);
- virtual ~Gateway();
-
- void run();
- void stop();
-
- void listen(QHostAddress address, ushort port);
- void stopListening();
-
- QList<QString>
- getConnectedHostList();
- void sendToHost(QString host, NetMsg* msg);
-
-
-private:
- NetPortalManager* portMan;
- Logger* log;
-
-};
-
-#endif /* __GATEWAY_H__ */
-
-/*
- * Local Variables:
- * tab-width: 8
- * mode: C
- * indent-tabs-mode: t
- * c-file-style: "stroustrup"
- * End:
- * ex: shiftwidth=4 tabstop=8
- */
Modified: rt^3/trunk/include/GeometryService.h
===================================================================
--- rt^3/trunk/include/GeometryService.h 2010-09-15 15:09:45 UTC (rev
40578)
+++ rt^3/trunk/include/GeometryService.h 2010-09-15 16:26:19 UTC (rev
40579)
@@ -26,7 +26,6 @@
#ifndef __GEOMETRYSERVICE_H__
#define __GEOMETRYSERVICE_H__
-#include "libnet.h"
#include "libutility.h"
#include <QTcpSocket>
@@ -34,21 +33,15 @@
#include <QStringList>
#include <QCoreApplication>
-class GeometryService : public INetMsgHandler
+class GeometryService
{
public:
GeometryService(const QString localGSHostname);
virtual ~GeometryService();
-// void startListening(const QHostAddress& addy, quint16 port);
-// void stopListening();
-// bool isListening() const;
-
private:
Logger* log;
QString localGSHostname;
-
- void handleNetMsg(NetMsg* msg, NetPortal* origin);
};
#endif
Modified: rt^3/trunk/include/NetPortal.h
===================================================================
--- rt^3/trunk/include/NetPortal.h 2010-09-15 15:09:45 UTC (rev 40578)
+++ rt^3/trunk/include/NetPortal.h 2010-09-15 16:26:19 UTC (rev 40579)
@@ -26,67 +26,11 @@
#ifndef __NETPORTAL_H__
#define __NETPORTAL_H__
-#include "NetMsgTypes.h"
-#include "NetMsg.h"
-#include "RemoteGSHostnameSetMsg.h"
-
-#include "libutility.h"
-#include "libevent.h"
-
-#include <QtNetwork/QTcpServer>
-#include <QtNetwork/QTcpSocket>
-#include <QtCore/QString>
-
-class INetMsgHandler;
-class NetPortalManager;
-class NetMsgFactory;
-
-class NetPortal: public QObject, public EventPublisher
+class NetPortal
{
-Q_OBJECT
-
public:
- NetPortal(NetPortalManager* parent, INetMsgHandler* handler);
- NetPortal(NetPortalManager* parent, INetMsgHandler* handler, int
socketDescriptor);
+ NetPortal();
virtual ~NetPortal();
-
- void connectToNetHost(QString netHostname, quint16 port);
- void connectToNetHost(QHostAddress address, quint16 port);
- void disconnectFromNetHost(quint8 reason = LOCAL_DISCONNECT_REQ);
-
- void checkFactory();
-
- void send(NetMsg& msg);
- void sendOpcodeOnlyMsg(quint32 opcode);
-
- QString getRemoteGSHostname();
-
- bool isOpen();
-
- enum HandshakeStatus
- {
- NotConnected = 0, Handshaking = 5, Ready = 10, Failed = 15,
- };
-
- void sendLocalGSHostnameToRemoteGSHost();
-
-protected slots:
- void moveDataFromSocketBuffer();
- void relaySockConnected();
- void relaySockDisconnected();
- void relaySockError(QAbstractSocket::SocketError err);
-
-private:
- QTcpSocket* sock;
- NetPortalManager* nspm;
- QString remGSHostname;
- NetMsgFactory* factory;
- HandshakeStatus handshakeStatus;
- Logger* log;
- INetMsgHandler* handler;
-
- void constructorCommon(NetPortalManager* nspm, INetMsgHandler* handler);
- void updateHandshakeStatus(HandshakeStatus newStatus);
};
#endif
Modified: rt^3/trunk/include/NetPortalManager.h
===================================================================
--- rt^3/trunk/include/NetPortalManager.h 2010-09-15 15:09:45 UTC (rev
40578)
+++ rt^3/trunk/include/NetPortalManager.h 2010-09-15 16:26:19 UTC (rev
40579)
@@ -27,51 +27,14 @@
#define __NETPORTALMANAGER_H__
#include "libutility.h"
-#include "libevent.h"
-#include "NetMsg.h"
-#include "INetMsgHandler.h"
-#include <QtNetwork/QTcpServer>
-#include <QtNetwork/QHostAddress>
-#include <QMap>
-#include <QUuid>
-#include <QList>
-#include <QByteArray>
+#include <Qt>
-class NetPortal;
-
-class NetPortalManager: public QTcpServer, public EventSubscriber
+class NetPortalManager
{
-
public:
- NetPortalManager(QString GSHostname, INetMsgHandler* handler, QObject*
parent = 0);
+ NetPortalManager(quint32 port);
~NetPortalManager();
-
- QString getLocalGSHostname();
- NetPortal* getNewPortal(int socketDescriptor = 0);
- NetPortal* getPortalByRemoteGSHostname(QString remHostname);
- void localLog(QString str);
-
- void handleEvent(Event* e);
-
- void mapPortalToGSHostname(NetPortal* portal);
- void unmapPortalToGSHostname(NetPortal* portal);
-
-protected:
- void incomingConnection(int socketDescriptor);
-
-private:
- void registerPortal(NetPortal* portal);
- void unregisterPortal(NetPortal* portal);
- NetPortal* preparePortal();
-
- QString localGSHostname;
- Logger* log;
-
- QMap<QString, NetPortal*>* gsHostnameToPortalMap;
- QList<NetPortal*>* portalList;
-
- INetMsgHandler* handler;
};
#endif
Modified: rt^3/trunk/src/GS/GeometryService.cxx
===================================================================
--- rt^3/trunk/src/GS/GeometryService.cxx 2010-09-15 15:09:45 UTC (rev
40578)
+++ rt^3/trunk/src/GS/GeometryService.cxx 2010-09-15 16:26:19 UTC (rev
40579)
@@ -35,47 +35,10 @@
GeometryService::~GeometryService()
{
-// delete this->portalMan;
-}
-//
-//void GeometryService::startListening(const QHostAddress& addy, quint16 port)
-//{
-// this->log->logINFO("GeometryService", localGSHostname + " is listening
on " + addy.toString() + ":" + QString::number(port));
-// this->portalMan->listen(addy, port);
-//}
-//
-//void GeometryService::stopListening()
-//{
-// this->log->logINFO("GeometryService", localGSHostname + " stopped
listening.");
-// this->portalMan->close();
-//}
-//
-//bool GeometryService::isListening() const
-//{
-// return this->portalMan->isListening();
-//}
-void GeometryService::handleNetMsg(NetMsg* msg, NetPortal* origin)
-{
- quint32 msgType = msg->getMsgType();
-
- switch (msgType) {
-
- case (NEWSESSIONREQ):
- {
- //Route to SessionManager
- SessionManager::getInstance()->handleNetMsg(msg, origin);
-
- break;
- }
- default:
- {
- throw new GSException("Does not handle this MsgType");
- break;
- }
- };
}
+
// Local Variables: ***
// mode: C++ ***
// tab-width: 8 ***
Modified: rt^3/trunk/src/GS/SessionManager.cxx
===================================================================
--- rt^3/trunk/src/GS/SessionManager.cxx 2010-09-15 15:09:45 UTC (rev
40578)
+++ rt^3/trunk/src/GS/SessionManager.cxx 2010-09-15 16:26:19 UTC (rev
40579)
@@ -47,49 +47,7 @@
return SessionManager::pInstance;
}
-void SessionManager::handleNetMsg(NetMsg* msg, NetPortal* origin)
-{
- quint32 msgType = msg->getMsgType();
- switch (msgType) {
-
- case (NEWSESSIONREQ):
- {
- NewSessionReqMsg* nstMsg = (NewSessionReqMsg*) msg;
-
- QString uname = nstMsg->getUName();
- QString passwd = nstMsg->getPasswd();
-
- quint32 accountID =
- AccountManager::getInstance()->validateLoginCreds(uname,
- passwd);
-
- if (accountID > 0) {
- Session* session = this->newSession(accountID);
- this->sessionIdMap->insert(accountID, session);
-
- // use reply cstr.
- SessionInfoMsg siMsg(msg, session->getSessionID() );
-
- //Send back reply
- origin->send(siMsg);
- } else {
- FailureMsg fMsg(msg, AUTHENTICATION_FAILED);
-
- //Send back reply
- origin->send(fMsg);
- }
-
- break;
- }
- default:
- {
- throw new GSException("Does not handle this MsgType");
- break;
- }
- };
-
-}
Session* SessionManager::newSession(quint32 accountID)
{
Session* s = new Session(accountID);
Modified: rt^3/trunk/src/GS/SessionManager.h
===================================================================
--- rt^3/trunk/src/GS/SessionManager.h 2010-09-15 15:09:45 UTC (rev 40578)
+++ rt^3/trunk/src/GS/SessionManager.h 2010-09-15 16:26:19 UTC (rev 40579)
@@ -27,16 +27,14 @@
#define __SESSIONMANAGER_H__
#include "Session.h"
-#include "libnet.h"
#include <QtCore/QMap>
-class SessionManager: public INetMsgHandler
+class SessionManager
{
public:
static SessionManager* getInstance();
virtual ~SessionManager();
- void handleNetMsg(NetMsg* msg, NetPortal* origin);
private:
static SessionManager* pInstance;
Modified: rt^3/trunk/src/GS/gsmain.cxx
===================================================================
--- rt^3/trunk/src/GS/gsmain.cxx 2010-09-15 15:09:45 UTC (rev 40578)
+++ rt^3/trunk/src/GS/gsmain.cxx 2010-09-15 16:26:19 UTC (rev 40579)
@@ -52,22 +52,5 @@
log->logBANNER("GSMain", "Booting GeometryService: " + gsHostname);
- QString listenAddressStr = c->getConfigValue("ListenAddress");
- if (listenAddressStr == "") {
- listenAddressStr = "localhost";
- }
- QHostAddress listenAddress(listenAddressStr);
-
- QString listenPortStr = c->getConfigValue("ListenPort");
- if (listenPortStr == "") {
- listenPortStr = "5309";
- }
- quint16 listenPort = listenPortStr.toShort();
-
- /*
- GeometryService gs(gsHostname);
- gs.startListening(listenAddress, listenPort);
- */
-
return 0;
}
Modified: rt^3/trunk/src/libNet/CMakeLists.txt
===================================================================
--- rt^3/trunk/src/libNet/CMakeLists.txt 2010-09-15 15:09:45 UTC (rev
40578)
+++ rt^3/trunk/src/libNet/CMakeLists.txt 2010-09-15 16:26:19 UTC (rev
40579)
@@ -44,7 +44,6 @@
#set Source files
RT3_PROJECT_ADD_SOURCES (
- Gateway.cxx
NetPortal.cxx
NetPortalManager.cxx
NetMsgFactory.cxx
@@ -68,7 +67,7 @@
#Set INST Headers
RT3_PROJECT_ADD_INST_HEADERS(
- Gateway.h
+ NetPortal.h
NetPortalManager.h
NetMsgTypes.h
INetMsgHandler.h
@@ -92,14 +91,10 @@
)
#Set NOINST headers
-RT3_PROJECT_ADD_NOINST_HEADERS(
+RT3_PROJECT_ADD_NOINST_HEADERS()
-)
-
#Set QT INST headers
-RT3_PROJECT_ADD_QT_INST_HEADERS(
- NetPortal.h
-)
+RT3_PROJECT_ADD_QT_INST_HEADERS()
#Set QT NOINST headers
RT3_PROJECT_ADD_QT_NOINST_HEADERS()
Deleted: rt^3/trunk/src/libNet/Gateway.cxx
===================================================================
--- rt^3/trunk/src/libNet/Gateway.cxx 2010-09-15 15:09:45 UTC (rev 40578)
+++ rt^3/trunk/src/libNet/Gateway.cxx 2010-09-15 16:26:19 UTC (rev 40579)
@@ -1,90 +0,0 @@
-/* G A T E W A Y . C X X
- * BRLCAD
- *
- * Copyright (c) 2010 United States Government as represented by
- * the U.S. Army Research Laboratory.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this file; see the file named COPYING for more
- * information.
- */
-/** @file Gateway.cxx
- *
- * Brief description
- *
- */
-
-#include "Gateway.h"
-#include "NetPortalManager.h"
-
-Gateway::Gateway(QString gsHostname, INetMsgHandler* handler)
-{
- this->log = Logger::getInstance();
- this->portMan = new NetPortalManager(gsHostname, handler);
-}
-
-Gateway::~Gateway()
-{
- delete this->portMan;
-}
-
-void Gateway::run()
-{
- this->log->logINFO("Gateway", "Run CMD received.");
- this->exec();
-}
-
-void Gateway::stop()
-{
- this->log->logINFO("Gateway", "Stop CMD received.");
- this->quit();
-}
-
-void Gateway::listen(QHostAddress address, ushort port)
-{
- if (this->isRunning() == false) {
- this->log->logINFO("Gateway", "Attempted to Listen on a Gateway that is
not running.");
- return;
- }
- this->portMan->listen(address, port);
-}
-
-void Gateway::stopListening()
-{
- if (this->isRunning() == false) {
- this->log->logINFO("Gateway", "Attempted to stop listening on a
Gateway that is not running.");
- return;
- }
- this->portMan->close();
-}
-
-QList<QString> Gateway::getConnectedHostList()
-{
-}
-
-void Gateway::sendToHost(QString host, NetMsg* msg)
-{
- if (this->isRunning() == false) {
- this->log->logINFO("Gateway", "Attempted to sendToHost on a Gateway
that is not running.");
- return;
- }
-
-}
-
-// 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
Modified: rt^3/trunk/src/libNet/NetPortal.cxx
===================================================================
--- rt^3/trunk/src/libNet/NetPortal.cxx 2010-09-15 15:09:45 UTC (rev 40578)
+++ rt^3/trunk/src/libNet/NetPortal.cxx 2010-09-15 16:26:19 UTC (rev 40579)
@@ -24,256 +24,16 @@
*/
#include "NetPortal.h"
-#include "NetPortalManager.h"
-#include "NetMsgFactory.h"
-#include "TypeOnlyMsg.h"
-#include <QtNetwork/QHostAddress>
-
-NetPortal::NetPortal(NetPortalManager* nspm, INetMsgHandler* handler)
+NetPortal::NetPortal()
{
- this->constructorCommon(nspm, handler);
- this->handshakeStatus = NotConnected;
}
-NetPortal::NetPortal(NetPortalManager* nspm, INetMsgHandler* handler, int
socketDescriptor)
-{
- this->constructorCommon(nspm, handler);
- this->handshakeStatus = Handshaking;
- this->sock->setSocketDescriptor(socketDescriptor);
-}
-
-void NetPortal::constructorCommon(NetPortalManager* nspm, INetMsgHandler*
handler)
-{
- this->log = Logger::getInstance();
- this->nspm = nspm;
- this->handler = handler;
- this->sock = new QTcpSocket();
- this->factory = new NetMsgFactory();
-
- QObject::connect(sock, SIGNAL(connected()), this,
- SLOT(relaySockConnected()));
- QObject::connect(sock, SIGNAL(disconnected()), this, SLOT(
- relaySockDisconnected()));
- QObject::connect(sock, SIGNAL(error(QAbstractSocket::SocketError)),
this,
- SLOT(relaySockError(QAbstractSocket::SocketError)));
-
- QObject::connect(sock, SIGNAL(readyRead()), this, SLOT(
- moveDataFromSocketBuffer()));
-}
-
NetPortal::~NetPortal()
{
-
}
-/************************/
-/* QTcpSocket Delegates */
-/************************/
-void NetPortal::connectToNetHost(QString netHostname, quint16 port)
-{
- this->sock->connectToHost(netHostname, port);
-}
-void NetPortal::connectToNetHost(QHostAddress address, quint16 port)
-{
- this->sock->connectToHost(address, port);
-}
-void NetPortal::disconnectFromNetHost(quint8 reason)
-{
- QString msg;
- msg += "Disconnected from: " + this->sock->peerAddress().toString() + "
("
- + this->remGSHostname + "). Reason code: " + reason +
"\n";
- this->log->logINFO("NetPortal", msg);
-
- this->sock->disconnectFromHost();
-}
-
-/***************************/
-/* QTcpSocket Signal Relay */
-/***************************/
-void NetPortal::relaySockConnected()
-{
- this->sendLocalGSHostnameToRemoteGSHost();
- this->updateHandshakeStatus(NetPortal::Handshaking);
- this->generateEvent(EVENTTYPE_PORTAL_CONNECT, "Received new
connected.");
-}
-void NetPortal::relaySockDisconnected()
-{
- this->updateHandshakeStatus(NetPortal::NotConnected);
- this->generateEvent(EVENTTYPE_PORTAL_DISCONNECT, this->remGSHostname +
" has been disconnected.");
-}
-void NetPortal::relaySockError(QAbstractSocket::SocketError err)
-{
- log->logERROR("NetPortal", "Socket generated an error: " +
QString::number(err));
-}
-
-/***************/
-/* Handshaking */
-/***************/
-
-void NetPortal::updateHandshakeStatus(HandshakeStatus newStatus)
-{
- if (this->handshakeStatus != newStatus)
- {
- //HandshakeStatus oldStatus = this->handshakeStatus;
- this->handshakeStatus = newStatus;
- }
-}
-void NetPortal::sendLocalGSHostnameToRemoteGSHost()
-{
- NetPortalManager* portMan = this->nspm;
- QString name = portMan->getLocalGSHostname();
- RemoteGSHostnameSetMsg msg(name);
- this->send(msg);
-}
-
-/*****************/
-/* Incoming Data */
-/*****************/
-
-void NetPortal::moveDataFromSocketBuffer()
-{
- //get data off socket
- QByteArray data = this->sock->readAll();
- //put into factory buffer & attempt a msg build.
- this->factory->addData(data);
- this->checkFactory();
-}
-
-void NetPortal::checkFactory()
-{
- NetMsg* msg = this->factory->makeMsg();
-
- while (msg != NULL) {
- quint32 type = msg->getMsgType();
-
- switch (this->handshakeStatus)
- {
- case (NetPortal::Ready):
- {
- //Check to see if the Msg received is Portal Control
- if (type == DISCONNECTREQ)
- {
- this->disconnectFromNetHost(REM_HOST_DISCONNECT);
- break;
- }
-
- this->handler->handleNetMsg(msg, this);
-
- break;
- }
- case (NetPortal::NotConnected):
- case (NetPortal::Handshaking):
- {
- this->updateHandshakeStatus(NetPortal::Handshaking);
-
- if (type != REMGSHOSTNAMESET)
- {
-
this->disconnectFromNetHost(PORTAL_HANDSHAKE_FAILURE);
- delete msg;
- break;
- }
-
- QString remoteHostname =
- ((RemoteGSHostnameSetMsg*)
msg)->getRemoteGSHostname();
-
- delete msg;
-
- //Zero length check
- if (remoteHostname.isEmpty())
- {
-
this->disconnectFromNetHost(PORTAL_HANDSHAKE_FAILURE);
- break;
- }
-
- //If the nspm returns a NetPortal object, then this
host is already on the network!
- if
(this->nspm->getPortalByRemoteGSHostname(remoteHostname) != NULL)
- {
-
this->disconnectFromNetHost(PORTAL_HANDSHAKE_FAILURE);
- break;
- }
-
- this->remGSHostname = remoteHostname;
- this->updateHandshakeStatus(NetPortal::Ready);
-
this->generateEvent(EVENTTYPE_PORTAL_HANDSHAKE_COMPLETE, remoteHostname + " has
completed handshaking.");
-
- break;
- }
- default:
- //Should be failed
- this->disconnectFromNetHost(PORTAL_HANDSHAKE_FAILURE);
- break;
- }
-
- //Try to make another message and loop.
- msg = this->factory->makeMsg();
- }
- //
this->nspm->localLog(QString::number(this->factory->getInboxSize())
- // + " Msgs in factory inbox.");
-}
-
-/**
- * This function is used to send an 'opcode only' style message.
- */
-void NetPortal::sendOpcodeOnlyMsg(quint32 opcode)
-{
- TypeOnlyMsg msg(opcode);
- this->send(msg);
-}
-
-/**
- * This function blocks until all data is sent.
- */
-void NetPortal::send(NetMsg& msg)
-{
- QByteArray ba;
- msg.serialize(&ba);
-
- QString str = "Sending msg of type: " +
QString::number(msg.getMsgType())
- + ", id: " + msg.getMsgUUID() + ", length: " +
QString::number(
- ba.size());
- this->nspm->localLog(str);
-
- quint64 totalToSend = ba.size();
- quint64 thisSend = 0;
- quint64 totalSent = 0;
-
- //TODO needs to be a better way to do this
- while (totalSent < totalToSend)
- {
- thisSend = this->sock->write(ba);
-
- //Check for socket failure
- if (thisSend == -1)
- {
- this->disconnectFromNetHost(PORTAL_WRITE_FAILURE);
- return;
- }
-
- //Check for Zero bytes sent
- if (thisSend == 0)
- {
- if (totalSent != totalToSend)
- {
- std::cerr << "Did not send all data from Msg to
host: "
- <<
this->remGSHostname.toStdString() << "\n";
- }
- return;
- }
- totalSent += thisSend;
- }
-}
-
-QString NetPortal::getRemoteGSHostname()
-{
- return this->remGSHostname;
-}
-
-bool NetPortal::isOpen() {
- return this->sock->isOpen();
-}
-
// Local Variables: ***
// mode: C++ ***
// tab-width: 8 ***
Modified: rt^3/trunk/src/libNet/NetPortalManager.cxx
===================================================================
--- rt^3/trunk/src/libNet/NetPortalManager.cxx 2010-09-15 15:09:45 UTC (rev
40578)
+++ rt^3/trunk/src/libNet/NetPortalManager.cxx 2010-09-15 16:26:19 UTC (rev
40579)
@@ -24,118 +24,15 @@
*/
#include "NetPortalManager.h"
-#include "NetPortal.h"
-#include "RemoteGSHostnameSetMsg.h"
-#include <QtNetwork/QTcpSocket>
-#include <iostream>
-NetPortalManager::NetPortalManager(QString localGSHostame,
- INetMsgHandler* handler, QObject* parent) :
- localGSHostname(localGSHostame), handler(handler), QTcpServer(parent)
+NetPortalManager::NetPortalManager(quint32 port)
{
- this->log = Logger::getInstance();
- this->gsHostnameToPortalMap = new QMap<QString, NetPortal*> ();
- this->portalList = new QList<NetPortal*> ();
}
NetPortalManager::~NetPortalManager()
{
- //TODO delete map and list?
}
-NetPortal* NetPortalManager::getNewPortal(int socketDescriptor)
-{
- //Create new NSP
- NetPortal* portal;
- if (socketDescriptor == 0) {
- portal = new NetPortal(this, handler);
- }
- else {
- portal = new NetPortal(this, handler, socketDescriptor);
- }
-
- this->registerPortal(portal);
-
- EventManager::getInstance()->subscribe(this,
- EVENTTYPE_PORTAL_DISCONNECT, portal);
-
- EventManager::getInstance()->subscribe(this,
- EVENTTYPE_PORTAL_HANDSHAKE_COMPLETE, portal);
-
- return portal;
-}
-
-void NetPortalManager::registerPortal(NetPortal* portal)
-{
- this->portalList->append(portal);
-}
-
-void NetPortalManager::mapPortalToGSHostname(NetPortal* portal)
-{
- this->gsHostnameToPortalMap->insert(portal->getRemoteGSHostname(), portal);
-}
-
-void NetPortalManager::unregisterPortal(NetPortal* portal)
-{
- this->portalList->removeAll(portal);
-}
-
-void NetPortalManager::unmapPortalToGSHostname(NetPortal* portal)
-{
- this->gsHostnameToPortalMap->remove(portal->getRemoteGSHostname());
-}
-
-void NetPortalManager::incomingConnection(int socketDescriptor)
-{
- NetPortal* nsp = this->getNewPortal(socketDescriptor);
-
- //Send the localhostName to the Remote machine.
- nsp->sendLocalGSHostnameToRemoteGSHost();
-
-}
-
-
-NetPortal* NetPortalManager::getPortalByRemoteGSHostname(QString remGSHostname)
-{
- return NetPortalManager::gsHostnameToPortalMap->value(remGSHostname, NULL);
-}
-
-QString NetPortalManager::getLocalGSHostname()
-{
- return this->localGSHostname;
-}
-
-void NetPortalManager::localLog(QString str)
-{
- QString nStr = "[" + this->localGSHostname + "] " + str;
- this->log->logINFO("NetPortalManager", nStr);
-}
-
-void NetPortalManager::handleEvent(Event* e)
-{
- quint32 type = e->getEventType();
-
- switch (type) {
- case EVENTTYPE_PORTAL_HANDSHAKE_COMPLETE:
- {
- NetPortal* np = (NetPortal*) e->getPublisher();
- this->mapPortalToGSHostname(np);
- }
- break;
- case EVENTTYPE_PORTAL_DISCONNECT:
- {
- NetPortal* np = (NetPortal*) e->getPublisher();
- this->unregisterPortal(np);
- this->unmapPortalToGSHostname(np);
-
- }
- break;
- default:
- //unhandled Event type;
- return;
- }
-}
-
// Local Variables:
// tab-width: 8
// mode: C++
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