Revision: 40709
          http://brlcad.svn.sourceforge.net/brlcad/?rev=40709&view=rev
Author:   davidloman
Date:     2010-09-27 18:53:21 +0000 (Mon, 27 Sep 2010)

Log Message:
-----------
Implemented Portal<->Portal handshaking.

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

Modified: rt^3/trunk/include/Portal.h
===================================================================
--- rt^3/trunk/include/Portal.h 2010-09-27 18:47:50 UTC (rev 40708)
+++ rt^3/trunk/include/Portal.h 2010-09-27 18:53:21 UTC (rev 40709)
@@ -28,20 +28,23 @@
 
 #define PKG_MAGIC2      5309
 
+#include "INetMsgHandler.h"
 #include "PkgTcpClient.h"
 #include "NetMsg.h"
 #include "brlcad/pkg.h"
 
 #include <QtCore/QString>
 
-class Portal
+class Portal : public INetMsgHandler
 {
 public:
   friend class PortalManager;
   virtual ~Portal();
   int send(NetMsg* msg);
+  void sendGSNodeName();
 
   QString getRemoteNodeName();
+  bool handleNetMsg(NetMsg* msg);
 
 protected:
   Portal(PkgTcpClient* client);
@@ -59,6 +62,7 @@
   PkgTcpClient* pkgClient;
   QString remoteNodeName;
   Logger* log;
+  bool handshakeComplete;
 
   static void callbackSpringboard(struct pkg_conn* conn, char* buf);
 };

Modified: rt^3/trunk/src/libNet/Portal.cxx
===================================================================
--- rt^3/trunk/src/libNet/Portal.cxx    2010-09-27 18:47:50 UTC (rev 40708)
+++ rt^3/trunk/src/libNet/Portal.cxx    2010-09-27 18:53:21 UTC (rev 40709)
@@ -27,6 +27,8 @@
 #include "Logger.h"
 #include "brlcad/bu.h"
 #include "NetMsgFactory.h"
+#include "NetMsgTypes.h"
+#include "RemoteGSHostnameSetMsg.h"
 
 Portal::Portal(PkgTcpClient* client)
 {
@@ -40,6 +42,7 @@
 
   this->pkgClient->setCallBackTable(table);
   this->log = Logger::getInstance();
+  this->handshakeComplete = false;
 }
 
 Portal::~Portal()
@@ -54,7 +57,18 @@
        delete ba;
        return retval;
 }
+void
+Portal::sendGSNodeName()
+{
+       QString localNodeName = 
Config::getInstance()->getConfigValue("LocalGSNodeName");
+       if (localNodeName.length() == 0) {
+               localNodeName = QUuid::createUuid().toString();
+       }
 
+       RemoteGSHostnameSetMsg* msg = new RemoteGSHostnameSetMsg(localNodeName);
+       this->send(msg);
+}
+
 int
 Portal::read(){
 
@@ -92,6 +106,22 @@
   return this->remoteNodeName + "";
 }
 
+bool
+Portal::handleNetMsg(NetMsg* msg)
+{
+       quint16 type = msg->getMsgType();
+
+       if (type == REMGSHOSTNAMESET) {
+               RemoteGSHostnameSetMsg* t = (RemoteGSHostnameSetMsg*)msg;
+               this->remoteNodeName = t->getRemoteGSHostname();
+               this->handshakeComplete = true;
+               delete msg;
+               return true;
+       }
+
+       return false;
+}
+
 void
 Portal::callbackSpringboard(struct pkg_conn* conn, char* buf)
 {
@@ -107,6 +137,9 @@
    }
   Portal* p = (Portal*)conn->pkc_user_data;
 
+  //TODO Split the code here?  Fire off a Job?
+
+
   /* Build a NetMsg */
   NetMsg* msg  = NetMsgFactory::getInstance()->deserializeNetMsg(ba, p);
 
@@ -117,6 +150,12 @@
   }
 
   /* Route */
+
+  //give the Portal first dibs on the netmsg
+  if (p->handleNetMsg(msg)){
+         return;
+  }
+
   //TODO add in routing code.
 }
 

Modified: rt^3/trunk/src/libNet/PortalManager.cxx
===================================================================
--- rt^3/trunk/src/libNet/PortalManager.cxx     2010-09-27 18:47:50 UTC (rev 
40708)
+++ rt^3/trunk/src/libNet/PortalManager.cxx     2010-09-27 18:53:21 UTC (rev 
40709)
@@ -176,7 +176,7 @@
                         * Do we really need Write checking?
                         */
                        if (FD_ISSET(i, &writefds)) {
-                       this->log->logINFO("PortalManager", "Write.");
+                               this->log->logINFO("PortalManager", "Write.");
 
                                /*
                                //Portal->write here.
@@ -226,6 +226,9 @@
                fdmax = newFD;
                this->masterFDSLock.unlock();
        }
+
+       newPortal->sendGSNodeName();
+
        return newPortal;
 }
 


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