当前位置: 首页>>代码示例>>PHP>>正文


PHP ZMQSocket::on方法代码示例

本文整理汇总了PHP中ZMQSocket::on方法的典型用法代码示例。如果您正苦于以下问题:PHP ZMQSocket::on方法的具体用法?PHP ZMQSocket::on怎么用?PHP ZMQSocket::on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZMQSocket的用法示例。


在下文中一共展示了ZMQSocket::on方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: registerHandlers

 /**
  *
  */
 private function registerHandlers()
 {
     $this->hbSocket->on('error', new HbErrorHandler($this->logger->withName('HbErrorHandler')));
     $this->hbSocket->on('messages', new HbMessagesHandler($this->logger->withName('HbMessagesHandler')));
     $this->iopubSocket->on('messages', new IOPubMessagesHandler($this->logger->withName('IOPubMessagesHandler')));
     $this->shellSocket->on('messages', new ShellMessagesHandler($this->broker, $this->iopubSocket, $this->shellSocket, $this->logger->withName('ShellMessagesHandler')));
 }
开发者ID:Litipk,项目名称:Jupyter-PHP,代码行数:10,代码来源:KernelCore.php

示例2: initZmq

 /**
  * @param LoopInterface $loop
  */
 public function initZmq(LoopInterface $loop)
 {
     /** @var \ZMQContext $context */
     $context = new \React\ZMQ\Context($loop);
     $this->listener = $context->getSocket(\ZMQ::SOCKET_PUSH);
     $this->listener->connect('tcp://127.0.0.1:5559');
     $this->receiver = $context->getSocket(\ZMQ::SOCKET_PULL);
     $this->receiver->connect('tcp://127.0.0.1:5557');
     $this->receiver->on('message', function ($msg) {
         $message = json_decode($msg, true);
         if (is_array($message) && isset($message['outputs']) && is_array($message['outputs'])) {
             $cumulative = array();
             foreach ($message['outputs'] as $output) {
                 $script = pack("H*", $output['script']);
                 if (!isset($cumulative[$script])) {
                     $cumulative[$script] = $output['value'];
                 } else {
                     $cumulative[$script] += $output['value'];
                 }
             }
             $message['requirements'] = $cumulative;
             $this->contracts[$message['slug']] = $message;
             echo "New contract: " . $msg . "\n";
         }
     });
 }
开发者ID:Bit-Wasp,项目名称:payment-requests,代码行数:29,代码来源:CoinWorker.php

示例3: declarePushMessaging

 /**
  * @return null
  */
 protected function declarePushMessaging()
 {
     $this->pullActionInfo->on(EventsConstants::MESSAGE, function ($pushDto) {
         $this->resolvePushMessage(unserialize($pushDto));
         $this->logger->debug("Receive push message {$pushDto}.");
     });
     $this->pullActionInfo->on(EventsConstants::ERROR, function ($error) {
         $this->logger->error(LoggingExceptions::getExceptionString($error));
     });
     return null;
 }
开发者ID:jamset,项目名称:publisher-pulsar,代码行数:14,代码来源:Pulsar.php

示例4: registerInboundEvents

 /**
  * Registers inbound data events.
  */
 private function registerInboundEvents()
 {
     // Handle requests from queue via SUBSCRIBER
     $this->zmqInboundQueue->on('message', function ($msg) {
         $this->runtimeStatistics->incrementAddedObjectCount();
         try {
             $message = RequestMessage::fromStringToArray($msg);
             $this->getQueue()->push($message['key'], $message['data'], round(microtime(true) * 1000000) + $message['timeout'], $message['type']);
             if ($this->isInLogLevel(Logger::DEBUG)) {
                 $this->logger->debug("[OnMessage] Data for key '{$message['key']}' [type '{$message['type']}', exp {$message['timeout']} ms]: " . str_replace("\n", "", var_export($message['data'], true)));
             }
         } catch (\Exception $e) {
             $this->logger->error($e);
         }
     });
 }
开发者ID:awdn,项目名称:vigilant-queue,代码行数:19,代码来源:DeferredQueue.php

示例5: declareReplyToPm

 protected function declareReplyToPm()
 {
     $this->replyToPmSocket = $this->context->getSocket(\ZMQ::SOCKET_REP);
     $this->replyToPmSocket->bind($this->loadManagerDto->getPmLmSocketsParams()->getPmLmRequestAddress());
     $this->replyToPmSocket->on(EventsConstants::ERROR, function (\Exception $e) {
         $this->logger->error(LoggingExceptions::getExceptionString($e));
     });
     $this->replyToPmSocket->on(EventsConstants::MESSAGE, function ($receivedDtoContainer) {
         /**
          * @var DtoContainer $dtoContainer
          */
         $dtoContainer = unserialize($receivedDtoContainer);
         $this->processReceivedControlDto($dtoContainer->getDto());
         $this->receivePmInfo = true;
         $this->replyToPmSocket->send(serialize($this->dtoContainer));
     });
     return null;
 }
开发者ID:jamset,项目名称:process-load-manager,代码行数:18,代码来源:Lm.php

示例6: declareLmRequester

 protected function declareLmRequester()
 {
     $this->lmRequesterSocket = $this->context->getSocket(\ZMQ::SOCKET_REQ);
     $this->lmRequesterSocket->connect($this->processManagerDto->getPmLmSocketsParams()->getPmLmRequestAddress());
     $this->lmRequesterSocket->on(EventsConstants::ERROR, function (\Exception $e) {
         $this->logger->error(LoggingExceptions::getExceptionString($e));
     });
     $this->lmRequesterSocket->on(EventsConstants::MESSAGE, function ($receivedDtoContainer) {
         $this->logger->alert("Received dto from LM." . $this->loggerPostfix);
         usleep($this->processManagerDto->getInterMessageInterval());
         /**
          * @var DtoContainer $dtoContainer
          */
         $dtoContainer = unserialize($receivedDtoContainer);
         $this->processReceivedControlDto($dtoContainer->getDto());
         if ($this->allowSending) {
             $this->lmRequesterSocket->send(serialize($this->dtoContainer));
             $this->logger->alert("Send a request " . $this->requestNumber . $this->loggerPostfix);
             $this->requestNumber++;
         }
     });
 }
开发者ID:jamset,项目名称:process-load-manager,代码行数:22,代码来源:Pm.php


注:本文中的ZMQSocket::on方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。