]> git.mxchange.org Git - hub.git/blob - application/hub/main/class_HubCoreLoop.php
some comments fixed, small fix for windows OSes and some other things fixed
[hub.git] / application / hub / main / class_HubCoreLoop.php
1 <?php
2 /**
3  * The hub's main loop. The hub will wait and listen for incoming requests in
4  * this loop.
5  *
6  * @author              Roland Haeder <webmaster@ship-simu.org>
7  * @version             0.0
8  * @copyright   Copyright(c) 2007, 2008 Roland Haeder, this is free software
9  * @license             GNU GPL 3.0 or any newer version
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23  */
24 class HubCoreLoop extends BaseFrameworkSystem {
25         /**
26          * Wether the hub is active and running
27       */
28         private $hubActivated = false;
29
30         /**
31          * Wether the hub is shutting down
32       */
33         private $hubShutsDown = false;
34
35         /**
36          * A list of all connected peers (sockets)
37          */
38         private $connectedPeers = null;
39
40         /**
41          * A console output handler
42          */
43         private $outputInstance = null;
44
45         /**
46          * Reading peers
47          */
48         private $readPeers = array();
49
50         /**
51          * Writing peers
52          */
53         private $writePeers = array();
54
55         /**
56          * The main socket (listening) for this hub
57          */
58         private $main_socket = null;
59
60         /**
61          * A list of authenticated peers
62          */
63         private $authPeers = null;
64
65         /**
66          * Last peer instance
67          */
68         private $lastPeerInstance = null;
69
70         /**
71          * Wether this hub is a master hub
72          */
73         private $hubIsMaster = false;
74
75         /**
76          * Maximum auth retries (cached)
77          */
78         private $authRetries = 0;
79
80         /**
81          * Auth request message
82          */
83         private $authRequest = "";
84
85         /**
86          * Cached timeout for auth requests
87          */
88         private $authRequestTimeout = 0;
89
90         /**
91          * An instance to the HubConnector class for master hub connection
92          */
93         private $masterConnector = null;
94
95         // Exception codes
96         const EXCEPTION_SOCKET_PROBLEM          = 0xb00;
97         const EXCEPTION_HUB_PEER_TIMEOUT                = 0xb01;
98         const EXCEPTION_HUB_PEER_FAILED_AUTH    = 0xb02;
99         const EXCEPTION_HELLO_TIMED_OUT         = 0xb03;
100
101         /**
102          * The private constructor
103          *
104          * @return      void
105          */
106         private function __construct () {
107                 // Call parent constructor
108                 parent::constructor(__CLASS__);
109
110                 // Set description
111                 $this->setPartDescr("Hub-Core Loop");
112
113                 // Set unique ID
114                 $this->createUniqueID();
115
116                 // Tidy up a little
117                 $this->removeSystemArray();
118                 $this->removeNumberFormaters();
119
120                 // Init the peer list
121                 $this->initPeerList();
122         }
123
124         /**
125          * Factory for main loop
126          *
127          * @return      $hubInstance            An instance of this class
128          */
129         public final static function createHubCoreLoop () {
130                 // Get an instance
131                 $hubInstance = new HubCoreLoop();
132
133                 // Try to setup the socket
134                 $hubInstance->setupHub();
135
136                 // Get the configuration variable
137                 $outEngine = $hubInstance->getConfigInstance()->readConfig("tpl_engine");
138
139                 // Setup the console output handler
140                 $eval = sprintf("\$hubInstance->setOutputInstance(%s::create%s(\"%s\"));",
141                         $outEngine,
142                         $outEngine,
143                         $hubInstance->getConfigInstance()->readConfig("web_content_type")
144                 );
145
146                 // Debug message
147                 if ((defined('DEBUG_EVAL')) || (defined('DEBUG_ALL'))) $hubInstance->getDebugInstance()->output(sprintf("[%s:] Konstruierte PHP-Anweisung: %s",
148                         $hubInstance->__toString(),
149                         htmlentities($eval)
150                 ));
151                 @eval($eval);
152
153                 // Return the prepared instance
154                 return $hubInstance;
155         }
156
157         /**
158          * Initializes the peer list
159          *
160          * @return      void
161          */
162         private final function initPeerList () {
163                 $this->connectedPeers = new FrameworkArrayObject();
164                 $this->authPeers      = new FrameworkArrayObject();
165         }
166
167         /**
168          * Get total number of connected peers
169          *
170          * @return      $num            The total number of connected peers
171          */
172         private final function getTotalConnectedPeers () {
173                 $read = array($this->connectedPeers->getIterator()->current());
174                 $write = array();
175                 $except = array();
176
177                 // Get socket number
178                 $num = socket_select(
179                         $read,
180                         $write,
181                         $except,
182                         0
183                 );
184
185                 // Transfer readers and writers
186                 $this->readPeers = $read;
187                 $this->writePeers = $write;
188
189                 // Return the number
190                 return $num;
191         }
192
193         /**
194          * Handle newly connected peers
195          *
196          * @return      void
197          */
198         private final function handleNewPeers () {
199                 // Output message
200                 $this->getOutputInstance()->output(sprintf("[%s] Validating peer...", __METHOD__));
201
202                 // Is the main socket in the array?
203                 if (in_array($this->main_socket, $this->readPeers)) {
204                         // Accept the connection and add him to the list
205                         $peer_socket = socket_accept($this->main_socket);
206
207                         // Get a new peer instance
208                         $this->setCurrPeerInstance(HubPeer::createHubPeerBySocket($peer_socket, $this));
209
210                         // Register the new peer
211                         $this->getOutputInstance()->output(sprintf("[%s] Registering new peer with IP %s.",
212                                 __METHOD__,
213                                 $this->getCurrPeerInstance()->getValidatedIP()
214                         ));
215                         $this->connectedPeers->append($this->lastPeerInstance);
216
217                         // A new peer has connected
218                         $this->getOutputInstance()->output(sprintf("[%s] New peer with IP %s has been registered.",
219                                 __METHOD__,
220                                 $this->getCurrPeerInstance()->getValidatedIP()
221                         ));
222
223                         // Remove him from the list
224                         $key = array_search($this->main_socket, $this->readPeers);
225                         unset($this->readPeers[$key]);
226                 } // END - if
227         }
228
229         /**
230          * Handles unauthenticated peers
231          *
232          * @return      void
233          * @throws      HubPeerTimeoutException                 If the peer times out to answer a request
234          * @throws      HubPeerAuthorizationException           If the peer fails to authorize himself (to many retries)
235          */
236         private final function handleUnauthPeers () {
237                 // Are there some peers?
238                 if ($this->connectedPeers->count() > 1) {
239                         // Iterate through all connected peers
240                         for ($idx = $this->connectedPeers->getIterator(); $idx->valid(); $idx->next()) {
241                                 // Get current peer
242                                 $this->lastPeerInstance = $idx->current();
243
244                                 // Ignore own socket and invalid entries
245                                 if (($this->getCurrPeerInstance() !== $this->main_socket) && (is_object($this->getCurrPeerInstance())) && ($this->getCurrPeerInstance() instanceof HubPeer)) {
246                                         // Is this peer already authorized or is this the master hub?
247                                         // If this is the master hub then there is no auth required
248                                         if ((!$this->getCurrPeerInstance()->ifPeerIsAuthorized()) && (!$this->getCurrPeerInstance()->ifPeerIsLocalAdmin()) && (!$this->hubIsMaster)) {
249                                                 // This peer waits for authorization, so does he have some tries left?
250                                                 if ($this->getCurrPeerInstance()->getAuthRetries() <= $this->authRetries) {
251                                                         // This peer is still allowed to try his authorization
252                                                         if ($this->getCurrPeerInstance()->getLastSentMessage() == $this->authRequest) {
253                                                                 // Already asked so maybe timed out?
254                                                                 if ((time() - $this->getCurrPeerInstance()->getLastSentMessageStamp()) >= $this->authRequestTimeout) {
255                                                                         // Timed out so disconnect the peer
256                                                                         throw new HubPeerTimeoutException (
257                                                                                 array(
258                                                                                         'this'  => $this,
259                                                                                         'peer'  => $this->getCurrPeerInstance()
260                                                                                 ), self::EXCEPTION_HUB_PEER_TIMEOUT
261                                                                         );
262                                                                 } // END - if
263                                                         } elseif ($this->getCurrPeerInstance()->ifHelloReceived()) {
264                                                                 // HELLO received so we need to sent the AUTH request
265                                                                 $this->getCurrPeerInstance()->askAuthorizationKey();
266                                                         }
267                                                 } else {
268                                                         // This peer needs disconnecting!
269                                                         throw new HubPeerAuthorizationException (
270                                                                 array(
271                                                                         'this'  => $this,
272                                                                         'peer'  => $this->getCurrPeerInstance(),
273                                                                         'max'   => $this->authRetries
274                                                                 ), self::EXCEPTION_HUB_PEER_FAILED_AUTH
275                                                         );
276                                                 } // END - else
277                                         } elseif ((!$this->getCurrPeerInstance()->ifPeerIsAuthorized()) && ($this->getCurrPeerInstance()->ifPeerIsLocalAdmin())) {
278                                                 // This peer is a local admin so he is always authorized!
279                                                 $this->getCurrPeerInstance()->enableLocalAdmin();
280
281                                                 // Output debug message
282                                                 $this->getOutputInstance()->output(sprintf("[%s] A local admin has connected.",
283                                                         $this->__toString()
284                                                 ));
285
286                                                 // Say "hi" to the admin
287                                                 $this->getCurrPeerInstance()->sayHi2Admin();
288                                         } elseif (($this->hubIsMaster) && ($this->getCurrPeerInstance()->ifHelloReceived()) && (!$this->getCurrPeerInstance()->ifELHOsent())) {
289                                                 // Is the master hub so authorize the peer here...
290                                                 $this->getCurrPeerInstance()->enableIsAuthorized();
291                                                 $this->authPeers->append($this->getCurrPeerInstance());
292
293                                                 // Reply the HELLO request
294                                                 $this->getCurrPeerInstance()->replyHelloMessage();
295                                         }
296                                 } // END - if
297                         } // END - for
298                 } // END - if
299         }
300
301         /**
302          * Handles only authorized peers
303          *
304          * @return      void
305          */
306         public function handleAuthPeers () {
307                 // Are there some peers?
308                 if (($this->connectedPeers->count() > 1) && ($this->authPeers->count() > 0)) {
309                         // Iterate through all connected peers
310                         for ($idx = $this->authPeers->getIterator(); $idx->valid(); $idx->next()) {
311                                 // Get current peer
312                                 $this->lastPeerInstance = $idx->current();
313
314                                 // Do the ping and update our authPeer list (LATER!)
315                                 $this->lastPeerInstance->handlePingPeer();
316                         } // END - for
317                 } // END - for
318         }
319
320         /**
321          * Setup the hub: Create a socket for listening on incoming requests,
322          * try to bind to a port, etc.
323          *
324          * @return      void
325          * @throws      SocketCreationException         If a socket cannot be created
326          * @throws      SocketSetupException            If a socket cannot be setuped
327          * @throws      SocketBindException                     If a socket cannot be bind to
328          *                                                                      an address and port
329          * @throws      SocketListeningException                If listening to a socket fails
330          */
331         private final function setupHub () {
332                 // Create a new TCP socket
333                 $main_socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
334
335                 // Was it a success?
336                 if (!is_resource($main_socket)) {
337                         // This fails! :(
338                         throw new SocketCreationException(
339                                 array(
340                                         'this' => $this,
341                                         'code' => socket_last_error()
342                                 ), self::EXCEPTION_SOCKET_PROBLEM
343                         );
344                 }
345
346                 // Set socket options
347                 if (!socket_set_option($main_socket, SOL_SOCKET, SO_REUSEADDR, 1)) {
348                         // Close the socket
349                         $this->closeSocket($main_socket);
350
351                         // Problems setting socket options
352                         throw new SocketSetupException (
353                                 array(
354                                         'this' => $this,
355                                         'code' => socket_last_error()
356                                 ), self::EXCEPTION_SOCKET_PROBLEM
357                         );
358                 }
359
360                 // Set to non-blocking
361                 socket_set_nonblock($main_socket);
362
363                 // Bind the socket to an address
364                 if (!socket_bind($main_socket, $this->getConfigInstance()->readConfig("hub_listen_addr"), $this->getConfigInstance()->readConfig("hub_listen_port"))) {
365                         // Bind failed
366                         throw new SocketBindException (
367                                 array(
368                                         'this' => $this,
369                                         'host' => $this->getConfigInstance()->readConfig("hub_listen_addr"),
370                                         'port' => $this->getConfigInstance()->readConfig("hub_listen_port"),
371                                         'code' => socket_last_error()
372                                 ), self::EXCEPTION_SOCKET_PROBLEM
373                         );
374                 }
375
376                 // Listen to ... the socket ;-)
377                 if (!socket_listen($main_socket)) {
378                         // Opps, that didn't work. Next time better listen to your heart... Roxette
379                         throw new SocketListeningException(
380                                 array(
381                                         'this' => $this,
382                                         'code' => socket_last_error()
383                                 ), self::EXCEPTION_SOCKET_PROBLEM
384                         );
385                 }
386
387                 // Ignore user abort and do not time out
388                 @set_time_limit(0);
389                 @ignore_user_abort(true);
390
391                 // Cache more configuration stuff
392                 $this->authRetries        = $this->getConfigInstance()->readConfig("hub_max_auth_tries");
393                 $this->authRequest        = $this->getConfigInstance()->readConfig("hub_auth_request");
394                 $this->authRequestTimeout = $this->getConfigInstance()->readConfig("hub_auth_request_timeout");
395
396                 // The hub is running now!
397                 $this->hubActivated = true;
398
399                 // Append the main hub
400                 $this->main_socket = $main_socket;
401                 $this->connectedPeers->append($main_socket);
402         }
403
404         /**
405          * Removes the current peer from the list
406          *
407          * @return      void
408          */
409         public final function removePeerFromConnectList () {
410                 // Iterate through all connected peers
411                 for ($idx = $this->connectedPeers->getIterator(); $idx->valid(); $idx->next()) {
412                         // Get current peer from list
413                         $peer = $idx->current();
414
415                         // Is it a peer instance?
416                         if (($peer !== $this->main_socket) && (is_object($peer)) && ($peer instanceof HubPeer)) {
417                                 // Okay, we have a peer instance so is it the same?
418                                 if ($this->getCurrPeerInstance()->equals($peer)) {
419                                         // Remove him!
420                                         $idx->offsetUnset($idx->key());
421                                         $this->lastPeerInstance = null;
422                                         break;
423                                 }
424                         }
425                 }
426         }
427
428         /**
429          * Getter for console output handler
430          *
431          * @return      $outputInstance An instance of the output handler
432          */
433         public final function getOutputInstance () {
434                 return $this->outputInstance;
435         }
436
437         /**
438          * Setter for console output handler
439          *
440          * @param               $outputInstance An instance of the output handler
441          */
442         public final function setOutputInstance ($outputInstance) {
443                 $this->outputInstance = $outputInstance;
444         }
445
446         /**
447          * Getter for current peer instance to HubPeer class
448          *
449          * @return      $lastPeerInstance               Last peer instance
450          */
451         public final function getCurrPeerInstance () {
452                 return $this->lastPeerInstance;
453         }
454
455         /**
456          * Setter for current peer instance to HubPeer class
457          *
458          * @param               $lastPeerInstance               Last peer instance
459          * @return      void
460          */
461         public final function setCurrPeerInstance (HubPeer $lastPeerInstance) {
462                 $this->lastPeerInstance = $lastPeerInstance;
463         }
464
465         /**
466          * Checks wether the hub is running and not in shutdown phase
467          *
468          * @return      $isRunning      If the hub is running and not in shutdown phase
469          */
470         public function ifHubIsRunning () {
471                 return ((($this->hubActivated) || (!$this->hubShutsDown)) && ($this->connectedPeers->count() > 0));
472         }
473
474         /**
475          * Output the intro text
476          *
477          * @return      void
478          */
479         public final function outputIntro () {
480                 if ($this->getConfigInstance()->readConfig("hub_intro_enabled") == "Y") {
481                         // Output intro text
482                         $this->getOutputInstance()->output(sprintf("%s v%s Copyright (c) 2007, 2008 by Roland H&auml;der",
483                                 ApplicationHelper::getInstance()->getAppName(),
484                                 ApplicationHelper::getInstance()->getAppVersion()
485                         ));
486                         $this->getOutputInstance()->output("");
487                         $this->getOutputInstance()->output("This software is free software licensed under the GNU GPL. In telnet session enter &quot;/license&quot; to read the license.");
488                         $this->getOutputInstance()->output("This software uses the MXChange Framework, Copyright (c) 2007, 2008 by Roland H&auml;der which is licensed under the GNU GPL.");
489                         $this->getOutputInstance()->output("Enter &quot;/framework&quot; in telnet session to read that license.");
490                         $this->getOutputInstance()->output("");
491                         $this->getOutputInstance()->output("All core systems are initialized. Input on *this* console will currently be ignored!");
492                         $this->getOutputInstance()->output("");
493                         $this->getOutputInstance()->output(sprintf("[%s] Listening on: %s:%d",
494                                 $this->__toString(),
495                                 $this->getConfigInstance()->readConfig("hub_listen_addr"),
496                                 $this->getConfigInstance()->readConfig("hub_listen_port")
497                         ));
498                         $this->getOutputInstance()->output("----------------------------------------------------------------------------------------------------------------------------");
499                 }
500         }
501
502         /**
503           * Do the main loop
504           *
505           * @return     void
506           * @throws     SocketCreationException         If the main socket is not a resource
507           */
508          public function coreLoop () {
509                 // Is the main socket vailid?
510                 if (!is_resource($this->main_socket)) {
511                         // Is not valid!
512                         throw new SocketCreationException(
513                                 array(
514                                         'this'  => $this,
515                                         'code'  => socket_last_error()
516                                 ), self::EXCEPTION_SOCKET_PROBLEM
517                         );
518                 } // END - if
519
520                 // We are ready to serve requests
521                 $this->getOutputInstance()->output(sprintf("[%s] Ready to serve requests.",
522                         $this->__toString()
523                 ));
524
525                 // Wait until the hub is shutting down
526                 while ($this->ifHubIsRunning()) {
527                         // Get number of total connected peers
528                         $num = $this->getTotalConnectedPeers();
529
530                         try {
531                                 // Handle the master hub connection
532                                 if ($this->masterConnector instanceof HubConnector) {
533                                         $this->masterConnector->handleMasterRequests();
534                                 }
535
536                                 // Check for unauthorized peers
537                                 $this->handleUnauthPeers();
538
539                                 // Handle authorized peers
540                                 $this->handleAuthPeers();
541                         } catch (HubPeerAuthorizationException $e) {
542                                 // Authorization has failed
543                                 $this->disconnectPeerWithReason("hub_msg_auth_tries");
544
545                                 // Get new total connected peers
546                                 $num = $this->getTotalConnectedPeers();
547                         } catch (HubPeerTimeoutException $e) {
548                                 // Disconnect and remove the peer
549                                 $this->disconnectPeerWithReason("hub_msg_auth_reply_timeout");
550
551                                 // Get new total connected peers
552                                 $num = $this->getTotalConnectedPeers();
553                         } catch (HubMasterDisconnectedException $e) {
554                                 // The master hub has disconnected us... :(
555                                 $this->masterConnector = null;
556                                 $this->getOutputInstance()->output(sprintf("[%s] The master has disconnected us. Reason given: %s",
557                                         $this->__toString(),
558                                         $e->getMessage()
559                                 ));
560                         } catch (BrokenPipeException $e) {
561                                 // Broken pipes are bad for us... :(
562                                 $this->removePeerFromConnectList();
563                                 $this->getOutputInstance()->output(sprintf("[%s] A peer has closed the connection unexpected: %s",
564                                         $this->__toString(),
565                                         $e->getMessage()
566                                 ));
567
568                                 // Get new total connected peers
569                                 $num = $this->getTotalConnectedPeers();
570                         } catch (FrameworkException $e) {
571                                 // Catch all other exceptions and output them
572                                 echo "CATCH".__LINE__.":".$e->__toString()."\n";
573                                 hub_exception_handler($e);
574
575                                 // Get new total connected peers
576                                 $num = $this->getTotalConnectedPeers();
577                         }
578
579                         // Are there some peers?
580                         if ($num < 1) {
581                                 // Wait for more peers
582                                 continue;
583                         } // END - if
584
585                         // A new peer has connected
586                         $this->getOutputInstance()->output(sprintf("[%s] A new peer is connecting.",
587                                 $this->__toString()
588                         ));
589
590                         try {
591                                 // Check for new peers
592                                 $this->handleNewPeers();
593                         } catch (IPSpoofingException $e) {
594                                 // Output message
595                                 $this->getOutputInstance()->output(sprintf("[%s] The peer's IP number has changed!",
596                                         $this->__toString()
597                                 ));
598
599                                 // Output debug message
600                                 $this->getDebugInstance()->output(sprintf("[%s] Peer spoofes IP number: %s",
601                                         $this->__toString(),
602                                         $e->getMessage()
603                                 ));
604
605                                 // Disconnect the peer first
606                                 $this->disconnectPeerWithReason("hub_msg_spoofing");
607
608                                 // Get new total connected peers
609                                 $num = $this->getTotalConnectedPeers();
610                         } catch (FrameworkException $e) {
611                                 // Catch all exceptions and output them to avoid aborting the program unexpectly
612                                 echo "CATCH".__LINE__.":".$e->__toString()."\n";
613                                 hub_exception_handler($e);
614
615                                 // Get new total connected peers
616                                 $num = $this->getTotalConnectedPeers();
617                         }
618
619                 } // END - while
620         }
621
622         /**
623          * Tries to contact the master server or simply reports that we are the master server
624          *
625          * @return      void
626          */
627         public function contactMasterHub () {
628                 // Checks wether we are the master hub
629                 if ($_SERVER['SERVER_ADDR'] == $this->getConfigInstance()->readConfig("hub_master_ip")) {
630                         // We are master!
631                         $this->hubIsMaster = true;
632                         $this->getOutputInstance()->output(sprintf("[%s] Our IP %s matches the master IP. Becoming master hub...",
633                                 $this->__toString(),
634                                 $_SERVER['SERVER_ADDR']
635                         ));
636                 } else {
637                         // A regular hub or ultra hub so let's contact the master
638                         $this->getOutputInstance()->output(sprintf("[%s] Contacting the master hub at %s:%d...",
639                                 $this->__toString(),
640                                 $this->getConfigInstance()->readConfig("hub_master_ip"),
641                                 $this->getConfigInstance()->readConfig("hub_master_port")
642                         ));
643
644                         // Try to aquire a connection to the master...
645                         try {
646                                 // Announce us to the master hub
647                                 $this->announceToMasterHub();
648                         } catch (FrameworkException $e) {
649                                 // Catch all exceptions and output them
650                                 echo "CATCH".__LINE__.":".$e->__toString()."\n";
651                                 hub_exception_handler($e);
652                         }
653                 } // END - else
654         }
655
656         /**
657          * Disconnects the current with a configurable reason
658          *
659          * @param               $reasonEntry    The entry with the disconnection reason aka. message to the peer
660          * @return      void
661          */
662          public function disconnectPeerWithReason ($reasonEntry) {
663                 $ip = "0.0.0.0";
664
665                 // Try to disconnect here
666                 try {
667                         // First get the raw IP number
668                         $ip = $this->getCurrPeerInstance()->getValidatedIP();
669
670                         // Disconnect the peer...
671                         $this->getCurrPeerInstance()->disconnectWithReason($this->getConfigInstance()->readConfig($reasonEntry));
672                 } catch (FrameworkException $e) {
673                         // Catch all exceptions and output them
674                         echo "CATCH".__LINE__.":".$e->__toString()."\n";
675                         hub_exception_handler($e);
676                 }
677
678                 // Remove him from the list anyway
679                 $this->removePeerFromConnectList();
680
681                 // Output the message
682                 $this->getOutputInstance()->output(sprintf("[%s] Peer %s has been disconnected.",
683                         $this->__toString(),
684                         $ip
685                 ));
686         }
687
688         /**
689          * Announces this hub to the master hub. This is being done by connecting to it and asking for auth request
690          *
691          * @return      void
692          */
693         public function announceToMasterHub () {
694                 try {
695                         // Create a new instance for communicating to the master hub
696                         $this->masterConnector = HubConnector::createHubConnectorByAddressPort(
697                                 $this->getConfigInstance()->readConfig("hub_master_ip"),
698                                 $this->getConfigInstance()->readConfig("hub_master_port"),
699                                 $this
700                         );
701
702                         // Send all our accepted objects to the master hub
703                         $this->masterConnector->sendAllAcceptedObjects();
704                 } catch (SocketConnectException $e) {
705                         // The master hub is down!
706                         ApplicationEntryPoint::app_die($e->getMessage());
707                 }
708         }
709
710 } // END - class
711
712 // [EOF]
713 ?>