]> git.mxchange.org Git - hub.git/commitdiff
Introduced new meta peer state 'problem'
authorRoland Häder <roland@mxchange.org>
Sat, 28 Apr 2012 08:37:05 +0000 (08:37 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 28 Apr 2012 08:37:05 +0000 (08:37 +0000)
.gitattributes
application/hub/config.php
application/hub/main/helper/connection/class_BaseConnectionHelper.php
application/hub/main/helper/connection/tcp/class_TcpConnectionHelper.php
application/hub/main/states/peer/errors/class_ProblemPeerState.php [new file with mode: 0644]

index 3f6d8cc60576e800e6759be7e07d3134d3baef7d..6382e8404151d01afc81fd852e50c9fb161c707d 100644 (file)
@@ -466,6 +466,7 @@ application/hub/main/states/peer/errors/class_ConnectionRefusedPeerState.php svn
 application/hub/main/states/peer/errors/class_ConnectionTimedOutPeerState.php svneol=native#text/plain
 application/hub/main/states/peer/errors/class_NoRouteToHostPeerState.php svneol=native#text/plain
 application/hub/main/states/peer/errors/class_OperationAlreadyProgressPeerState.php svneol=native#text/plain
 application/hub/main/states/peer/errors/class_ConnectionTimedOutPeerState.php svneol=native#text/plain
 application/hub/main/states/peer/errors/class_NoRouteToHostPeerState.php svneol=native#text/plain
 application/hub/main/states/peer/errors/class_OperationAlreadyProgressPeerState.php svneol=native#text/plain
+application/hub/main/states/peer/errors/class_ProblemPeerState.php svneol=native#text/plain
 application/hub/main/states/peer/errors/class_TransportEndpointGonePeerState.php svneol=native#text/plain
 application/hub/main/states/peer/init/.htaccess -text svneol=unset#text/plain
 application/hub/main/states/peer/init/class_InitPeerState.php svneol=native#text/plain
 application/hub/main/states/peer/errors/class_TransportEndpointGonePeerState.php svneol=native#text/plain
 application/hub/main/states/peer/init/.htaccess -text svneol=unset#text/plain
 application/hub/main/states/peer/init/class_InitPeerState.php svneol=native#text/plain
index a67e18f8991a569ea44c69f519c3706a62a8da5c..b1505b3528171fa3dc7d246096c6c35efadb2495 100644 (file)
@@ -589,6 +589,9 @@ $cfg->setConfigEntry('peer_init_state_class', 'InitPeerState');
 // CFG: PEER-CONNECTED-STATE-CLASS
 $cfg->setConfigEntry('peer_connected_state_class', 'ConnectedPeerState');
 
 // CFG: PEER-CONNECTED-STATE-CLASS
 $cfg->setConfigEntry('peer_connected_state_class', 'ConnectedPeerState');
 
+// CFG: PEER-PROBLEM-STATE-CLASS
+$cfg->setConfigEntry('peer_problem_state_class', 'ProblemPeerState');
+
 // CFG: PEER-CONNECTION-REFUSED-STATE-CLASS
 $cfg->setConfigEntry('peer_connection_refused_state_class', 'ConnectionRefusedPeerState');
 
 // CFG: PEER-CONNECTION-REFUSED-STATE-CLASS
 $cfg->setConfigEntry('peer_connection_refused_state_class', 'ConnectionRefusedPeerState');
 
index c854646427cb9d6068499d698051c3f94142f610..39fa404eb8c4448d79a39c986af436b38fa93b34 100644 (file)
@@ -252,6 +252,18 @@ class BaseConnectionHelper extends BaseHubHelper implements Registerable, Protoc
                        }
                } // END - while
 
                        }
                } // END - while
 
+               // Is the peer connected?
+               if ($isConnected === true) {
+                       // Connection is fully established here, so change the state.
+                       PeerStateFactory::createPeerStateInstanceByName('connected', $this);
+               } else {
+                       /*
+                        * There was a problem connecting to the peer (this state is a meta
+                        * state until the error handler has found the real cause).
+                        */
+                       PeerStateFactory::createPeerStateInstanceByName('problem', $this);
+               }
+
                // Return status
                return $isConnected;
        }
                // Return status
                return $isConnected;
        }
index d10b80f8809e229790672b189ee895b2c20aea87..9095b817bb387e7e8826b90b38268b7595be4f07 100644 (file)
@@ -130,9 +130,6 @@ class TcpConnectionHelper extends BaseConnectionHelper implements ConnectionHelp
                        $helperInstance->handleSocketError($socketResource, $recipientData);
                } // END - if
 
                        $helperInstance->handleSocketError($socketResource, $recipientData);
                } // END - if
 
-               // Connection is fully established here, so change the state
-               PeerStateFactory::createPeerStateInstanceByName('connected', $helperInstance);
-
                // Okay, that should be it. Return it...
                return $socketResource;
        }
                // Okay, that should be it. Return it...
                return $socketResource;
        }
diff --git a/application/hub/main/states/peer/errors/class_ProblemPeerState.php b/application/hub/main/states/peer/errors/class_ProblemPeerState.php
new file mode 100644 (file)
index 0000000..6f38848
--- /dev/null
@@ -0,0 +1,53 @@
+<?php
+/**
+ * A Problem peer state class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class ProblemPeerState extends BasePeerState implements PeerStateable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set state name
+               $this->setStateName(BaseRawDataHandler::SOCKET_ERROR_UNKNOWN);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $stateInstance  An instance of a PeerStateable class
+        */
+       public final static function createProblemPeerState () {
+               // Get new instance
+               $stateInstance = new ProblemPeerState();
+
+               // Return the prepared instance
+               return $stateInstance;
+       }
+}
+
+// [EOF]
+?>