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


PHP ZMQContext::getSocket方法代码示例

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


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

示例1: __construct

 public function __construct()
 {
     $this->servers = 0;
     $this->sequence = 0;
     $this->context = new ZMQContext();
     $this->socket = $this->context->getSocket(ZMQ::SOCKET_DEALER);
 }
开发者ID:inactivist,项目名称:zguide,代码行数:7,代码来源:flclient2.php

示例2: getSocket

 /**
  * @return \ZMQSocket
  */
 private function getSocket()
 {
     if (null == $this->pushSocket) {
         $this->pushSocket = $this->context->getSocket(\ZMQ::SOCKET_PUSH, 'my pusher');
         $this->pushSocket->connect("tcp://localhost:5555");
     }
     return $this->pushSocket;
 }
开发者ID:Bit-Wasp,项目名称:payment-requests,代码行数:11,代码来源:RequestApi.php

示例3: connect

 /**
  * Connects to the given endpoint
  */
 public function connect()
 {
     $this->context = new \ZMQContext();
     $this->socket = $this->context->getSocket(\ZMQ::SOCKET_PULL);
     if ($this->isDebug()) {
         ConsoleLog::log("Connecting to zmq at '{$this->getZmq()}'");
     }
     $this->socket->connect($this->getZmq());
 }
开发者ID:awdn,项目名称:vigilant-queue,代码行数:12,代码来源:Client.php

示例4: createSocket

 /**
  * @param $socketType
  * @param array $options
  * @param bool $justCreate
  * @return \ZMQSocket
  */
 protected function createSocket($socketType, array $options = [], $justCreate = false)
 {
     $socket = $this->context->getSocket($socketType);
     foreach ($options as $key => $value) {
         $socket->setSockOpt($key, $value);
     }
     if (!$justCreate) {
         $this->socket = $socket;
     }
     return $socket;
 }
开发者ID:limitium,项目名称:zmq,代码行数:17,代码来源:BaseBroker.php

示例5: _initSockets

 protected function _initSockets()
 {
     $this->log('starting to initialize sockets');
     $context = new \ZMQContext();
     $socket = $context->getSocket(\ZMQ::SOCKET_PAIR);
     $socket->connect(sprintf('ipc:///tmp/downloader-%d.ipc', $this->_downloadBundleId));
     $this->_socketToWorker = $socket;
     $socket = $context->getSocket(\ZMQ::SOCKET_DEALER);
     $socket->setSockOpt(\ZMQ::SOCKOPT_IDENTITY, sprintf('downloader/%s', uniqid()));
     $socket->connect($this->_config->get('sockets.queueManager'));
     $this->_socketToQueueManager = $socket;
     $this->_context = $context;
     $this->log('initialized sockets');
 }
开发者ID:sgraebner,项目名称:tp,代码行数:14,代码来源:Downloader.php

示例6: __construct

 public function __construct($sender_id, $sub_addr, $pub_addr)
 {
     $this->sender_id = $sender_id;
     $ctx = new \ZMQContext();
     $reqs = $ctx->getSocket(\ZMQ::SOCKET_UPSTREAM);
     $reqs->connect($sub_addr);
     $resp = $ctx->getSocket(\ZMQ::SOCKET_PUB);
     $resp->connect($pub_addr);
     $resp->setSockOpt(\ZMQ::SOCKOPT_IDENTITY, $sender_id);
     $this->sub_addr = $sub_addr;
     $this->pub_addr = $pub_addr;
     $this->reqs = $reqs;
     $this->resp = $resp;
 }
开发者ID:winks,项目名称:m2php,代码行数:14,代码来源:Connection.php

示例7: attack

 function attack()
 {
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $id = JRequest::getvar('id');
     $monster = $this->getMonster($id, $db);
     $player = $this->getPlayer($user, $db);
     $attackRoundMonster = $monster->defence + rand(0, 6);
     $attackRoundPlayer = $monster->attack + rand(0, 6);
     if ($attackRoundPlayer > $attackRoundMonster) {
         $query = "UPDATE #__jigs_monsters SET health = health -10 WHERE id= {$id}";
         $db->setQuery($query);
         $db->query();
         $message = 'You caused 10 hit points of damage';
         MessagesHelper::sendFeedback($user->id, $message);
     }
     $query = "SELECT health FROM  #__jigs_monsters WHERE id= {$id}";
     $db->setQuery($query);
     $result['id'] = $id;
     $result['health'] = $db->loadResult();
     $entryData = array('category' => 'monsterHealthCategory', 'title' => 'title', 'article' => $result, 'when' => time());
     $context = new ZMQContext();
     $socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher');
     if ($socket->connect("tcp://localhost:5555")) {
         //   echo 'connected';
     }
     if ($socket->send(json_encode($entryData))) {
         //  echo 'delivered';
     }
     return true;
 }
开发者ID:Rai-Ka,项目名称:JiGS-PHP-RPG-engine,代码行数:31,代码来源:monsters.php

示例8: handle

 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $reader = Reader::createFromPath($this->path);
     $read = 0;
     $saved = 0;
     foreach ($reader->fetchAssoc() as $row) {
         $read++;
         $artist = Artist::firstOrNew(['artist_id' => $row['artist_id']]);
         $artist->artist_id = $row['artist_id'];
         $artist->slug = $row['slug'];
         $artist->name = $row['name'];
         $artist->PID = $row['PID'];
         $artist->year_birth = $row['year_birth'];
         $artist->year_death = $row['year_death'];
         $artist->copyright = $row['copyright'];
         if ($artist->save()) {
             $saved++;
         }
     }
     $report = ['event' => 'artists.imported', 'data' => ['read' => $read, 'saved' => $saved]];
     $message = json_encode($report);
     $context = new \ZMQContext();
     $socket = $context->getSocket(\ZMQ::SOCKET_PUSH, 'my pusher');
     $socket->connect("tcp://localhost:5555");
     $socket->send($message);
 }
开发者ID:netsensei,项目名称:resin,代码行数:31,代码来源:importArtists.php

示例9: sendDataToServer

 /**
  * Отправка данных на сервер
  *
  * @param array $data
  */
 static function sendDataToServer(array $data)
 {
     $context = new \ZMQContext();
     $socket = $context->getSocket(\ZMQ::SOCKET_PUSH, 'my pusher');
     $socket->connect("tcp://localhost:5555");
     $socket->send(json_encode($data));
 }
开发者ID:a1ex7,项目名称:librauth,代码行数:12,代码来源:Pusher.php

示例10: init

 /**
  * @return void
  */
 protected function init()
 {
     $this->logger->info("Running " . self::class . " on " . str_replace("\n", "", `hostname; echo ' - ';uname -a;`));
     $this->logger->info("The eviction tick rate is set to {$this->config->getEvictionTicksPerSec()}/second.");
     // Create the event loop
     $this->reactLoop = React\EventLoop\Factory::create();
     // Object pool
     $this->queue = new PriorityHashQueue();
     // In default mode the latest data will be replaced for a given key. In DATA_MODE_APPEND the data will be appended
     // internally and available within the consumer as array (for instance for reducing purposes)
     //$this->queue->setDataMode(PriorityHashQueue::DATA_MODE_APPEND);
     // Setup ZMQ to send evicted objects.
     $this->zmqContext = new React\ZMQ\Context($this->reactLoop);
     $this->logger->info("Binding inbound ZMQ to '{$this->config->getZmqIn()}'.");
     // Receiver queue for incoming objects
     $this->zmqInboundQueue = $this->zmqContext->getSocket(\ZMQ::SOCKET_PULL);
     $this->zmqInboundQueue->bind($this->config->getZmqIn());
     $this->logger->info("Binding outbound ZMQ to '{$this->config->getZmqOut()}'.");
     // Outgoing queue for evicted objects
     $this->zmqOutboundQueue = $this->zmqContext->getSocket(\ZMQ::SOCKET_PUSH);
     $this->zmqOutboundQueue->bind($this->config->getZmqOut());
     // Register events
     $this->registerInboundEvents();
     $this->registerEvictionEvents();
     $this->registerTimedEvents();
 }
开发者ID:awdn,项目名称:vigilant-queue,代码行数:29,代码来源:DeferredQueue.php

示例11: handle

 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle(MergeManager $mergeManager, FileManager $fileManager)
 {
     $columns = ['PID', 'entity type', 'title', 'document type', 'URL', 'enabled', 'notes', 'format', 'reference', 'order'];
     $items = $mergeManager->fetchAll();
     $writer = Writer::createFromFileObject(new SplTempFileObject());
     $writer->insertOne($columns);
     $count = 0;
     foreach ($items as $item) {
         $row = [$item->object_number, $item->entity_type, $item->object->title, $item->url, $item->enabled, $item->format, $item->representation_order, $item->reference];
         $writer->insertOne($row);
         $count++;
     }
     $output = (string) $writer;
     $timestamp = Carbon::now();
     $fileName = sprintf("import_%s.csv", $timestamp->format('dmY_His'));
     $fileManager->saveFile($fileName, $output);
     $merger = new Merger();
     $merger->filename = $fileName;
     $merger->documents = $count;
     $merger->save();
     $context = new \ZMQContext();
     $socket = $context->getSocket(\ZMQ::SOCKET_PUSH, 'my pusher');
     $socket->connect("tcp://localhost:5555");
     $socket->send('test');
 }
开发者ID:netsensei,项目名称:resin,代码行数:30,代码来源:Merge.php

示例12: handle

 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $reader = Reader::createFromPath($this->path);
     $read = 0;
     $saved = 0;
     foreach ($reader->fetchAssoc() as $row) {
         $read++;
         $object_number = $row['object_number'];
         unset($row['object_number']);
         foreach ($row as $key => $value) {
             $document = Document::firstOrNew(['url' => $value]);
             $document->object_number = $object_number;
             $document->url = $value;
             if ($key == "data") {
                 $document->type = "data";
                 $document->order = "";
             } else {
                 list($type, $order) = explode("_", $key);
                 $document->type = $type;
                 $document->order = isset($order) ? $order : "";
             }
             if ($document->save()) {
                 $saved++;
             }
         }
     }
     $report = ['event' => 'documents.imported', 'data' => ['read' => $read, 'saved' => $saved]];
     $message = json_encode($report);
     $context = new \ZMQContext();
     $socket = $context->getSocket(\ZMQ::SOCKET_PUSH, 'my pusher');
     $socket->connect("tcp://localhost:5555");
     $socket->send($message);
 }
开发者ID:netsensei,项目名称:resin,代码行数:38,代码来源:importDocuments.php

示例13: initialize

function initialize()
{
    global $config, $queue;
    /* Load the config.  Create a publishing socket. */
    // Danger! Danger!
    $json = shell_exec("fedmsg-config");
    $config = json_decode($json, true);
    /* Just make sure everything is sane with the fedmsg config */
    if (!array_key_exists('relay_inbound', $config)) {
        echo "fedmsg-config has no 'relay_inbound'";
        return false;
    }
    $context = new ZMQContext(1, true);
    $queue = $context->getSocket(ZMQ::SOCKET_PUB, "pub-a-dub-dub");
    $queue->setSockOpt(ZMQ::SOCKOPT_LINGER, $config['zmq_linger']);
    if (is_array($config['relay_inbound'])) {
        // API for fedmsg >= 0.5.2
        // TODO - be more robust here and if connecting to the first one fails, try
        // the next, and the next, and etc...
        $queue->connect($config['relay_inbound'][0]);
    } else {
        // API for fedmsg <= 0.5.1
        $queue->connect($config['relay_inbound']);
    }
    # Go to sleep for a brief moment.. just long enough to let our zmq socket
    # initialize.
    if (array_key_exists('post_init_sleep', $config)) {
        usleep($config['post_init_sleep'] * 1000000);
    }
    return true;
}
开发者ID:bugcy013,项目名称:fedora_ansible,代码行数:31,代码来源:fedmsg-emit.php

示例14: wizmass_notifier_notification_send

/**
 * Send real-time notifications to subscribed users
 *
 * @param string $hook   Hook name
 * @param string $type   Hook type
 * @param bool   $result Has anyone sent a message yet?
 * @param array  $params Hook parameters
 * @return bool
 * @access private
 */
function wizmass_notifier_notification_send($hook, $type, $result, $params)
{
    /** @var WizmassNotifier\Interfaces\WizmassNotification $notification */
    $notification = $params['notification'];
    //echo 'got notification: ' . $notification->guid . PHP_EOL;
    //$ia = elgg_set_ignore_access(true);
    //echo 'got subjects: ' . count($notification->getSubjects()) . PHP_EOL;
    //elgg_set_ignore_access($ia);
    require __DIR__ . '/vendor/autoload.php';
    $context = new ZMQContext();
    $socket = $context->getSocket(ZMQ::SOCKET_PUSH, 'my pusher');
    $socket->connect("tcp://localhost:5555");
    $subjects = [];
    foreach ($notification->getSubjects() as $subject) {
        $subjects[] = array('guid' => $subject->guid);
    }
    $msg = new \stdClass();
    $msg->recipient_guids = $subjects;
    //$msg->recipient_guid = $recipient->guid;
    //    $msg->subject_name = $actor->getDisplayName();
    //    $msg->subject_url = $actor->getURL();
    //    $msg->target_name = $entity->getDisplayName();
    //    $msg->target_url = $entity->getURL();
    //    $msg->text = $string;
    //    $msg->icon_url = $actor->getIconURL();
    $msg->data = $notification->BuildNotificationData();
    //echo 'encoded notification data: ' . json_encode($msg) . PHP_EOL;
    $socket->send(json_encode($msg));
}
开发者ID:roybirger,项目名称:elgg-wizmass-notifier,代码行数:39,代码来源:start.php

示例15: worker_thread

function worker_thread()
{
    $context = new ZMQContext();
    $worker = $context->getSocket(ZMQ::SOCKET_REQ);
    $worker->connect("ipc://backend.ipc");
    //  Tell broker we're ready for work
    $worker->send("READY");
    while (true) {
        //  Read and save all frames until we get an empty frame
        //  In this example there is only 1 but it could be more
        $address = $worker->recv();
        // Additional logic to clean up workers.
        if ($address == "END") {
            exit;
        }
        $empty = $worker->recv();
        assert(empty($empty));
        //  Get request, send reply
        $request = $worker->recv();
        printf("Worker: %s%s", $request, PHP_EOL);
        $worker->send($address, ZMQ::MODE_SNDMORE);
        $worker->send("", ZMQ::MODE_SNDMORE);
        $worker->send("OK");
    }
}
开发者ID:inactivist,项目名称:zguide,代码行数:25,代码来源:lbbroker.php


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