コード例 #1
0
ファイル: ZmqModel.php プロジェクト: kraken-php/framework
 /**
  * Start time register.
  *
  * Time register purpose is to cyclically increase timestamp representing last active tick of event loop. This method
  * allows model to not mark external sockets wrongly as offline because of its own heavy load.
  */
 private function startTimeRegister()
 {
     if ($this->rTimer === null && $this->flags['enableHeartbeat'] === true && $this->flags['enableTimeRegister'] === true) {
         $proxy = $this;
         $this->rTimer = $this->loop->addPeriodicTimer($this->options['timeRegisterInterval'] / 1000, function () use($proxy) {
             $now = round(microtime(true) * 1000);
             $proxy->connectionPool->setNow(function () use($now) {
                 return $now;
             });
         });
     }
 }
コード例 #2
0
ファイル: ZmqSocket.php プロジェクト: kraken-php/framework
 /**
  * Close connection and discard not sent data.
  */
 public function close()
 {
     if ($this->closed) {
         return;
     }
     $this->emit('end', [$this]);
     $this->loop->removeStream($this->fd);
     $this->buffer->flushListeners();
     $this->flushListeners();
     unset($this->socket);
     $this->closed = true;
 }
コード例 #3
0
ファイル: ZmqBuffer.php プロジェクト: kraken-php/framework
 /**
  * Handle ZMQ Write Event.
  */
 public function handleWriteEvent()
 {
     foreach ($this->messages as $i => $message) {
         try {
             $message = (array) $message;
             $sent = (bool) $this->socket->sendmulti($message, ZMQ::MODE_DONTWAIT);
             unset($this->messages[$i]);
             if (0 === count($this->messages)) {
                 $this->loop->removeWriteStream($this->fd);
                 $this->listening = false;
                 $this->emit('end');
             }
         } catch (ZMQSocketException $ex) {
             $this->emit('error', [$ex]);
         }
     }
 }
コード例 #4
0
ファイル: ReactLoop.php プロジェクト: kraken-php/framework
 /**
  * @override
  * @inheritDoc
  */
 public function futureTick(callable $listener)
 {
     $this->loop->onAfterTick($listener);
 }