Example #1
0
 /**
  * Construct
  */
 public function __construct($host = '', $port = null)
 {
     parent::__construct($host, $port);
     // use port as queue name
     $this->mq = Pms_Adaptor::queue(array('name' => $port));
     $this->mq->addHandler(new Pms_Message_Handler());
     $this->port = $port;
 }
Example #2
0
 /**
  * Clear all queue on the server
  * Please be careful to this action !!!
  * 
  * @return void
  */
 public function clearAll()
 {
     foreach ($this->ports as $port) {
         $client = Pms_Adaptor::client(array('host' => $this->host, 'port' => $port));
         $client->clearMq();
     }
 }
Example #3
0
 /**
  * Select adaptor for PMS system
  * 
  * @static
  */
 public static function factory($adaptor)
 {
     self::$adaptor = $adaptor;
 }
Example #4
0
 /**
  * Process main logic
  */
 public function run()
 {
     // init first time
     if (!$this->port) {
         $ports = $this->ports;
         $this->port = array_pop($ports);
         // current process's port (no shared)
         $this->ports = $ports;
         // store children process pid
         // do only once !!!
         $this->__pid(true);
     } else {
         echo "\n";
     }
     echo "Listening on : " . $this->port . "\n";
     try {
         // start socket message queue server
         $server = Pms_Adaptor::server(array('host' => $this->host, 'port' => $this->port));
         $server->daemon();
     } catch (Exception $e) {
         Hush_Util::trace($e);
         $server->close();
         $this->run();
     }
 }