Ejemplo n.º 1
0
<?php

require_once "../../vendor/autoload.php";
use Hprose\Socket\Server;
function hello($name, $context)
{
    return "Hello {$name}! -- " . stream_socket_get_name($context->socket, true);
}
$server = new Server("tcp://0.0.0.0:1314");
$server->addFunction('hello', array("passContext" => true));
$server->start();
Ejemplo n.º 2
0
<?php

require_once "../../../vendor/autoload.php";
require_once '../CompressFilter.php';
require_once '../SizeFilter.php';
require_once '../StatFilter.php';
use Hprose\Socket\Server;
$server = new Server('tcp://0.0.0.0:1143/');
$server->addFilter(new StatFilter());
$server->addFilter(new SizeFilter('Non compressed'));
$server->addFilter(new CompressFilter());
$server->addFilter(new SizeFilter('Compressed'));
$server->addFilter(new StatFilter());
$server->addFunction(function ($value) {
    return $value;
}, 'echo');
$server->start();
Ejemplo n.º 3
0
<?php

require_once "../../../vendor/autoload.php";
require_once '../LogFilter.php';
use Hprose\Socket\Server;
use Hprose\Filter\JSONRPC;
use Hprose\Filter\XMLRPC;
function hello($name)
{
    return "Hello {$name}!";
}
$server = new Server('tcp://0.0.0.0:1143/');
$server->addFunction('hello');
$server->addFilter(new JSONRPC\ServiceFilter());
$server->addFilter(new XMLRPC\ServiceFilter());
$server->addFilter(new LogFilter());
$server->start();
Ejemplo n.º 4
0
<?php

require_once "../../../vendor/autoload.php";
require_once '../StatFilter.php';
use Hprose\Socket\Server;
$server = new Server('tcp://0.0.0.0:1143/');
$server->addFilter(new StatFilter());
$server->addFunction(function ($value) {
    return $value;
}, 'echo');
$server->start();
Ejemplo n.º 5
0
<?php

require_once "../../vendor/autoload.php";
use Hprose\InvokeSettings;
use Hprose\Http\Client;
use Hprose\Socket\Server;
use Hprose\ResultMode;
$client = new Client("http://www.hprose.com/example/", false);
$settings = new InvokeSettings(array("mode" => ResultMode::RawWithEndTag));
$proxy = function ($name, $args) use($client, $settings) {
    return $client->invoke($name, $args, $settings);
};
$server = new Server("tcp://0.0.0.0:1314");
$server->debug = true;
$server->addMissingFunction($proxy, array("mode" => ResultMode::RawWithEndTag));
$server->start();
Ejemplo n.º 6
0
<?php

require_once "../../../vendor/autoload.php";
require_once '../logHandler2.php';
use Hprose\Socket\Server;
function hello($name)
{
    return "Hello {$name}!";
}
$server = new Server('tcp://0.0.0.0:1143/');
$server->addFunction('hello');
$server->debug = true;
$server->addBeforeFilterHandler($logHandler2);
$server->start();
Ejemplo n.º 7
0
<?php

require_once "../../vendor/autoload.php";
use Hprose\Socket\Server;
function hello($name)
{
    return "Hello {$name}!";
}
$server = new Server("tcp://0.0.0.0:1314");
$server->setErrorTypes(E_ALL);
$server->setDebugEnabled();
$server->addFunction('hello');
$server->start();
Ejemplo n.º 8
0
<?php

require_once "../../../vendor/autoload.php";
require_once '../../filter/CompressFilter.php';
require_once '../SizeHandler.php';
require_once '../StatHandler.php';
require_once '../StatHandler2.php';
use Hprose\Socket\Server;
$server = new Server('tcp://0.0.0.0:1143/');
$server->addFunction(function ($value) {
    return $value;
}, 'echo')->addBeforeFilterHandler(array(new StatHandler2("BeforeFilter"), 'asynchandle'))->addBeforeFilterHandler(array(new SizeHandler("compressedr"), 'asynchandle'))->addFilter(new CompressFilter())->addAfterFilterHandler(array(new StatHandler2("AfterFilter"), 'asynchandle'))->addAfterFilterHandler(array(new SizeHandler("Non compressed"), 'asynchandle'))->addInvokeHandler(array(new StatHandler("Invoke"), 'asynchandle'))->start();
Ejemplo n.º 9
0
<?php

require_once "../../../vendor/autoload.php";
require_once '../coLogHandler.php';
use Hprose\Socket\Server;
function hello($name)
{
    return "Hello {$name}!";
}
$server = new Server('tcp://0.0.0.0:1143/');
$server->addFunction('hello');
$server->debug = true;
$server->addInvokeHandler($coLogHandler);
$server->start();
Ejemplo n.º 10
0
<?php

require_once "../../vendor/autoload.php";
use Hprose\Socket\Server;
function hello($name, $context)
{
    $context->clients->push("news", "this is a pushed message: {$name}");
    $context->clients->broadcast("news", array('x' => 1, 'y' => 2));
    return "Hello {$name}!";
}
$server = new Server("tcp://0.0.0.0:1980");
$server->publish('news');
$server->onSubscribe = function ($topic, $id, $service) {
    error_log("client {$id} subscribe {$topic} on " . microtime(true));
};
$server->onUnsubscribe = function ($topic, $id, $service) {
    error_log("client {$id} unsubscribe {$topic} on " . microtime(true));
};
$server->addFunction('hello', array('passContext' => true));
$server->start();
Ejemplo n.º 11
0
<?php

require_once "../../vendor/autoload.php";
use Hprose\Socket\Server;
use Hprose\Future;
$server = new Server("tcp://0.0.0.0:1315");
$server->setErrorTypes(E_ALL);
$server->setDebugEnabled();
$server->addFunction(function ($a, $b) use($server) {
    $promise = new Future();
    $server->after(1000, function () use($a, $b, $promise) {
        $promise->resolve($a + $b);
    });
    return $promise;
}, "sum");
$server->start();
Ejemplo n.º 12
0
<?php

require_once "../../vendor/autoload.php";
use Hprose\Socket\Server;
$server = new Server("tcp://0.0.0.0:2016");
$server->publish('time');
$server->tick(1000, function () use($server) {
    error_log(microtime(true));
    $server->push('time', microtime(true));
});
$server->start();
Ejemplo n.º 13
0
<?php

require_once "../../../vendor/autoload.php";
require_once '../LogFilter.php';
use Hprose\Socket\Server;
function hello($name)
{
    return "Hello {$name}!";
}
$server = new Server('tcp://0.0.0.0:1143/');
$server->addFunction('hello');
$server->addFilter(new LogFilter());
$server->start();