Revision: 40633
          http://brlcad.svn.sourceforge.net/brlcad/?rev=40633&view=rev
Author:   davidloman
Date:     2010-09-21 16:26:24 +0000 (Tue, 21 Sep 2010)

Log Message:
-----------
Change the Portal cstr that only the PortalManager should use to Protected.  
Implement Portal::sendRecv() which is handles all IO for that portal.

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-21 16:23:48 UTC (rev 40632)
+++ rt^3/trunk/include/Portal.h 2010-09-21 16:26:24 UTC (rev 40633)
@@ -35,15 +35,27 @@
 class Portal
 {
 public:
-       Portal(PkgTcpClient* client);
-       virtual ~Portal();
+  friend class PortalManager;
+  virtual ~Portal();
 
-       QString getRemoteNodeName();
+  /*
+   * Returns:
+   *          <0 on error
+   *          0 on EOF
+   *          >0 on success
+   */
+  int sendRecv();
+
+  QString getRemoteNodeName();
+
+protected:
+  Portal(PkgTcpClient* client);
+
 private:
-       PkgTcpClient* pkgClient;
-       QString remoteNodeName;
+  PkgTcpClient* pkgClient;
+  QString remoteNodeName;
 
-       static void callbackSpringboard(struct pkg_conn* conn, char* buf);
+  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-21 16:23:48 UTC (rev 40632)
+++ rt^3/trunk/src/libNet/Portal.cxx    2010-09-21 16:26:24 UTC (rev 40633)
@@ -44,6 +44,41 @@
 {
 }
 
+int
+Portal::sendRecv(){
+  int retval = 0;
+
+  //recv first
+  retval = this->pkgClient->processData();
+  if (retval < 0){
+      bu_log("Unable to process packets? Weird.\n");
+      return retval;
+  }//TODO do we need to check for ==0 ?
+
+
+  retval = this->pkgClient->pullDataFromSocket();
+  if (retval < 0) {
+    bu_log("Seemed to have trouble pulling the data from the socket.\n");
+    return retval;
+
+  } else if (retval == 0) {
+    bu_log("Client closed the connection.\n");
+    return retval;
+  }
+
+  retval = this->pkgClient->processData();
+  if (retval < 0){
+      bu_log("Unable to process packets? Weird.\n");
+      return retval;
+  }//TODO do we need to check for ==0 ?
+
+
+  //Now do send.
+  //TODO do send
+
+  return 1;
+}
+
 QString
 Portal::getRemoteNodeName(){
   return this->remoteNodeName + "";


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