예제 #1
0
파일: AmiSms.php 프로젝트: enniel/ami
 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']);
 }
예제 #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);
     });
 }