2017 © Pedro Peláez
 

library prime-rpc

image

xd/prime-rpc

  • Thursday, February 8, 2018
  • by ganxiangdong
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Prime-rpc is a basal and asynchronous RPC library, (*1)

Install


composer require xd/prime-rpc, (*2)

Examples


  1. Base on TCP, (*3)

    Server, (*4)

    <?php
    include 'vendor/autoload.php';
    $server = new \Xd\PrimeRpc\Server\TcpServer('yur server name', '0.0.0.0', '9501', 20);
    
    //bind receive event 
    \Xd\PrimeRpc\Server\IocEventServer::inject('receive', function($fd, $data){
       //do something...
    
       //output content at last
       $output = ['code' => 0, 'msg' => 'ok', 'result' => ['title' => "test={$data['test']}"]];
       return $output;
    });
    $server->start();
    

    Client, (*5)

    <?php
    //connect host
    $client = new Xd\PrimeRpc\Client\TcpClient('127.0.0.1', 9501);
    
    //send data
    $request1 = $client->request(['test' => '1']);
    //send data
    $request2 = $client->request(['test' => '2']);
    
    //get the second response data
    $res2 = $request2->receive();
    print_r($res2);
    
    //get the first response data
    $res1 = $request1->receive();
    print_r($res1);
    
    
  2. Base on HTTP Server, (*6)

    <?php
    include 'vendor/autoload.php';
    $server = new \Xd\PrimeRpc\Server\HttpServer('yur server name', '0.0.0.0', '9501', 20);
    
    //bind request event 
    \Xd\PrimeRpc\Server\IocEventServer::inject('request', function($request, $response){
       //do something...
    
       //output content at last
       $output = ['code' => 0, 'msg' => 'ok', 'result' => ['title' => "test={$request->get['test']}"]];
       return $output;
    });
      $server->start();
    

    Client: recommend use the github.com/ganxiangdong/async-http-client, (*7)

  3. Manage server
    shutdown: sh vender/src/server/bins/shutdown.sh
    reload: sh vender/src/server/bins/reload.sh, (*8)

  4. More information please visit github.com/swoole/swoole-src, (*9)

The Versions

08/02 2018

dev-master

9999999-dev https://github.com/ganxiangdong/x-rpc

  Sources   Download

MIT

The Requires

 

by xiangdonggan

light simple async rpc asynchronism basal

08/02 2018

v1.0.2

1.0.2.0 https://github.com/ganxiangdong/x-rpc

  Sources   Download

MIT

The Requires

 

by xiangdonggan

light simple async rpc asynchronism basal

04/01 2018

v1.0.1

1.0.1.0 https://github.com/ganxiangdong/x-rpc

  Sources   Download

MIT

The Requires

 

by xiangdonggan

light simple async rpc asynchronism basal

04/01 2018

v1.0.0

1.0.0.0 https://github.com/ganxiangdong/x-rpc

  Sources   Download

MIT

The Requires

 

by xiangdonggan

light simple async rpc asynchronism