Exemplo n.º 1
0
<?php

require __DIR__ . '/vendor/autoload.php';
$queueHost = getenv('QUEUE_PORT_8000_TCP_ADDR');
$queueUrl = "http://{$queueHost}:8000/listen.php";
$tasks = [['fibonacci', 5], ['fibonacci', 1], ['fibonacci', 10], ['mirror', 'muspi meroL'], ['mirror', '.alib akšrU ej cilked zi išpelran ,altevs acinad ej dzevz zi jlobrán oK - .enež en atelked ajtevc ejn usač bo eneležaz jlob olib mečo enebon ,enebon in olib ekšrU do išpel la,elevols eknajlbujL os épel jedkén dO'], ['encoder', 'my-secret-password'], ['encoder', '123456'], ['arithmetic', '3 + 4 * 2 / ( 1 - 5 ) ^ 2 ^ 3'], ['arithmetic', '2 * 4 + 5']];
sleep(3);
for ($ii = 0; $ii < 100; $ii++) {
    $key = array_rand($tasks);
    $client = new JsonRpc\Client($queueUrl);
    $client->call('enqueueTask', $tasks[$key]);
    usleep(rand(100000, 1000000));
}
Exemplo n.º 2
0
<?php

chdir(__DIR__);
ini_set('default_charset', 'UTF-8');
ini_set('display_errors', '1');
# bootstrap for the example directory
require 'bootstrap.php';
# get the url of the server script
$url = getServerUrl();
# create our client object, passing it the server url
$Client = new JsonRpc\Client($url);
# set up our rpc call with a method and params
$method = 'divide';
$params = array(42, 6);
$success = false;
$success = $Client->call($method, $params);
/*
# notify
$success = $Client->notify($method);
*/
/*
# batch sending
$Client->batchOpen();
$Client->call($method, $params);
$Client->notify($method, $params);
$Client->call($method, $params);
$Client->notify($method, $params);
$Client->call($method, $params);
$success = $Client->batchSend();
*/
echo '<form method="GET">';
Exemplo n.º 3
0
 /**
  * Send request to queue
  * @return boolean
  * @author Andraz <*****@*****.**>
  */
 public function startListening()
 {
     $client = new \JsonRpc\Client($this->getQueueUrl() . 'listen.php');
     $client->call('listen', [$this->getIp(), $this->getPort(), $this->getType()]);
 }