Esempio n. 1
0
 public function sendPdu()
 {
     $pdu = new Submit();
     $pdu->setAddress($this->argument('number'));
     $pdu->setData($this->argument('message'));
     $promises = [];
     foreach ($pdu->getParts() as $part) {
         $promises[] = $this->request('DongleSendPdu', ['Device' => $this->getDevice(), 'PDU' => (string) $part]);
     }
     $promise = \React\Promise\map($promises, function (Response $response) {
         Event::fire('ami.dongle.sms.sended', [$this, $response]);
         $message = Arr::get($response->getFields(), 'Message', null);
         $this->line($message);
     });
     $promise->then([$this, 'stop'], [$this, 'writeException']);
 }
Esempio n. 2
0
 public function pruneDeadWorkers()
 {
     $worker_pids = $this->workerPids();
     return Resque::redis()->smembers('workers')->then(function ($response) use($worker_pids) {
         $promises = \React\Promise\map($response, function ($workerId) use($worker_pids) {
             list($hostname, $pid, $queues) = explode(':', $workerId, 3);
             if ($hostname != $this->hostname || in_array($pid, $worker_pids) || $pid == getmypid()) {
                 return null;
             }
             $queues = explode(',', $queues);
             $worker = new self($queues, \Iwai\React\Resque::getEventLoop());
             $worker->setId($workerId);
             return $worker->unregisterWorker();
         });
         return \React\Promise\all($promises);
     });
 }