Revision: 40830
          http://brlcad.svn.sourceforge.net/brlcad/?rev=40830&view=rev
Author:   davidloman
Date:     2010-09-29 15:23:07 +0000 (Wed, 29 Sep 2010)

Log Message:
-----------
Wire up PortalManager's response to DISCONNECTREQ

Modified Paths:
--------------
    rt^3/trunk/include/PortalManager.h
    rt^3/trunk/src/libNet/PortalManager.cxx

Modified: rt^3/trunk/include/PortalManager.h
===================================================================
--- rt^3/trunk/include/PortalManager.h  2010-09-29 15:20:02 UTC (rev 40829)
+++ rt^3/trunk/include/PortalManager.h  2010-09-29 15:23:07 UTC (rev 40830)
@@ -29,6 +29,9 @@
 #include "libutility.h"
 #include "ControlledThread.h"
 #include "PkgTcpServer.h"
+#include "INetMsgHandler.h"
+#include "TypeOnlyMsg.h"
+
 #include <sys/select.h>
 
 #include <QtCore/QList>
@@ -37,7 +40,7 @@
 
 class Portal;
 
-class PortalManager : public ControlledThread
+class PortalManager : public ControlledThread, public INetMsgHandler
 {
 public:
        PortalManager(quint16 port = 0);
@@ -45,6 +48,7 @@
 
        Portal* connectToHost(QString host, quint16 port);
        void disconnect(Portal* p);
+    bool handleNetMsg(NetMsg* msg);
 
 protected:
        void _run();
@@ -64,7 +68,7 @@
        Portal* makeNewPortal(PkgTcpClient* client, struct pkg_switch* table);
        struct pkg_switch* makeNewSwitchTable();
        void closeFD(int fd, QString logComment);
-
+    void handleDisconnectReqMsg(TypeOnlyMsg* msg);
 };
 
 #endif

Modified: rt^3/trunk/src/libNet/PortalManager.cxx
===================================================================
--- rt^3/trunk/src/libNet/PortalManager.cxx     2010-09-29 15:20:02 UTC (rev 
40829)
+++ rt^3/trunk/src/libNet/PortalManager.cxx     2010-09-29 15:23:07 UTC (rev 
40830)
@@ -27,6 +27,7 @@
 #include "PortalManager.h"
 #include "NetMsgFactory.h"
 #include "PkgTcpClient.h"
+#include "NetMsgTypes.h"
 
 #include <stdio.h>
 #include <errno.h>
@@ -323,6 +324,33 @@
        this->closeFD(fd, "Disconnect requested.");
 }
 
+
+bool
+PortalManager::handleNetMsg(NetMsg* msg)
+{
+       quint16 type = msg->getMsgType();
+       switch(type) {
+       case DISCONNECTREQ:
+               this->handleDisconnectReqMsg((TypeOnlyMsg*)msg);
+               return true;
+       }
+       return false;
+}
+
+void
+PortalManager::handleDisconnectReqMsg(TypeOnlyMsg* msg)
+{
+       Portal* origin = msg->getOrigin();
+
+       //validate incoming data
+       if (origin == 0) {
+               //TODO Figure out how to how to handle NULL Portal
+               log->logERROR("PortalManager", "handleDisconnectReqMsg(): NULL 
Portal!");
+               return;
+       }
+
+       this->disconnect(origin);
+}
 // 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

Reply via email to