Revision: 40620
http://brlcad.svn.sourceforge.net/brlcad/?rev=40620&view=rev
Author: davidloman
Date: 2010-09-20 19:14:55 +0000 (Mon, 20 Sep 2010)
Log Message:
-----------
Make Portal a logical extension of pkg_conn. Add in basic support for handling
remote node names.
Modified Paths:
--------------
rt^3/trunk/include/Portal.h
rt^3/trunk/src/libNet/Portal.cxx
Modified: rt^3/trunk/include/Portal.h
===================================================================
--- rt^3/trunk/include/Portal.h 2010-09-20 19:08:31 UTC (rev 40619)
+++ rt^3/trunk/include/Portal.h 2010-09-20 19:14:55 UTC (rev 40620)
@@ -26,11 +26,24 @@
#ifndef __PORTAL_H__
#define __PORTAL_H__
+#define PKG_MAGIC2 5309
+
+#include <QtCore/QString>
+#include "PkgTcpClient.h"
+#include "brlcad/pkg.h"
+
class Portal
{
public:
- Portal();
+ Portal(PkgTcpClient* client);
virtual ~Portal();
+
+ QString getRemoteNodeName();
+private:
+ PkgTcpClient* pkgClient;
+ QString remoteNodeName;
+
+ static void callbackSpringboard(struct pkg_conn* conn, char* buf);
};
#endif
Modified: rt^3/trunk/src/libNet/Portal.cxx
===================================================================
--- rt^3/trunk/src/libNet/Portal.cxx 2010-09-20 19:08:31 UTC (rev 40619)
+++ rt^3/trunk/src/libNet/Portal.cxx 2010-09-20 19:14:55 UTC (rev 40620)
@@ -24,16 +24,61 @@
*/
#include "Portal.h"
+#include "brlcad/bu.h"
+#include "NetMsgFactory.h"
-Portal::Portal()
+Portal::Portal(PkgTcpClient* client)
{
+ this->remoteNodeName = "NotSetYet-" + QUuid::createUuid().toString();
+ this->pkgClient = client;
+
+ struct pkg_switch table[] = {
+ {PKG_MAGIC2, &(Portal::callbackSpringboard), "SpringBoard", this},
+ {0,0, (char*)0,0}
+ };
+
+ this->pkgClient->setCallBackTable(table);
}
Portal::~Portal()
{
}
+QString
+Portal::getRemoteNodeName(){
+ return this->remoteNodeName + "";
+}
+void
+Portal::callbackSpringboard(struct pkg_conn* conn, char* buf)
+{
+ /* Check to see if we got a good Buffer and Portal Object */
+ if (buf == 0) {
+ bu_bomb("pkg callback returned a NULL buffer!\n");
+ }
+
+ QByteArray ba(buf);
+
+ if (conn->pkc_user_data == 0) {
+ bu_bomb("pkg callback returned a NULL user_data pointer!\n");
+ }
+ Portal* p = (Portal*)conn->pkc_user_data;
+
+ /* Construct String */
+ QString origin(p->getRemoteNodeName());
+
+ /* Build a NetMsg */
+ NetMsg* msg = NetMsgFactory::getInstance()->deserializeNetMsg(ba, origin);
+
+ /* check to see if we deserialized the msg properly */
+ if (msg == 0) {
+ bu_log("WARNING! NetMsg failed to deserialize properly.\n");
+ }
+
+ /* Route */
+ //TODO add in routing code.
+}
+
// Local Variables: ***
// mode: C++ ***
// tab-width: 8 ***
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