Independent use of code

 * Created by PhpStorm.
 * User: xcg
 * Date: 2019/2/27
 * Time: 10:00
include_once dirname(__DIR__) . "/vendor/autoload.php";

use EasySwoole\Rpc\Config;
use EasySwoole\Rpc\Rpc;
use EasySwoole\Rpc\Request;
use EasySwoole\Rpc\Response;

$config = new Config();
//Registration Service Name
//Set up broadcast address, you can have more than one address
//Setting up the radio monitor address
//$config->setNodeManager(\EasySwoole\Rpc\NodeManager\TableManager::class);//Set up the node manager processing class, which defaults to EasySwoole\Rpc\NodeManager\FileManager

$rpc = new Rpc($config);
//Registration response method
$rpc->registerAction('call1', function (Request $request, Response $response) {
    //Get the request parameters
    //Settings returned to client information
//Registration response method 2
$rpc->registerAction('call2', function (Request $request, Response $response)

//Listen / broadcast RPC custom process object
$autoFindProcess = $rpc->autoFindProcess('es_rpc_process_1');

//Create a second RPC service
$config2=new Config();
$rpc2 = new Rpc($config2);

//Listen / broadcast RPC custom process object
$autoFindProcess2 = $rpc2->autoFindProcess('es_rpc_process_2');

//Create http swoole services
$http = new swoole_http_server("", 9525);

//Add a custom process to the service and start the process

//RPC runs as a sub-service
$sub = $http->addlistener("", 9527, SWOOLE_TCP);
$sub2 = $http->addlistener("", 9528, SWOOLE_TCP);

//Inject swoole tcp sub-service into RPC object and start listening processing

 * HTTP request callback
$http->on("request", function ($request, $response) {
    $response->end("Hello World\n");

////rpc Running as a primary service
//$tcp = new swoole_server('', 9526);


0 results matching ""

    No results matching ""