php-JsonRPC JsonRPC 的 PHP 扩展

程序名称:php-JsonRPC

授权协议: 未知

操作系统: 跨平台

开发语言: PHP

php-JsonRPC 介绍

JsonRPC 2.0 Client and Server

轻量级 Json-RPC 2.0 客户端和服务端的PHP扩展,基于 multi_curl +
epoll的并发客户端,依据jsonrpc协议规范

服务端:

$server = new Jsonrpc_Server();

// style one function variable
$add1 = function($a, $b){
    return $a + $b;
};
$server->register('addition1', $add1);

// style two function string
function add2($a, $b){
  return $a + $b;
}
$server->register('addition2', 'add2');

// style three function closure
$server->register('addition3', function ($a, $b) {
    return $a + $b;
});

//style four class method string
class A 
{
  static public function add($a, $b)
  {
    return $a + $b;
  }
}
$server->register('addition4', 'A::add');

echo $server->execute();

//output >>>
//{"jsonrpc":"2.0","id":null,"error":{"code":-32700,"message":"Parse error"}}

客户端:

$client = new Jsonrpc_Client(1);
$client->call('http://localhost/server.PHP', 'addition1', array(3,5));
$client->call('http://localhost/server.PHP', 'addition2', array(10,20));
$client->call('http://localhost/server.PHP', 'addition3', array(2,8));
$client->call('http://localhost/server.PHP', 'addition4', array(6,15));
/* ... */
$result = $client->execute();

var_dump($result);

//output >>>
/*
array(2) {
  [0]=>
  array(3) {
    ["jsonrpc"]=>
    string(3) "2.0"
    ["id"]=>
    int(110507766)
    ["result"]=>
    int(8)
  }
  [1]=>
  array(3) {
    ["jsonrpc"]=>
    string(3) "2.0"
    ["id"]=>
    int(1559316299)
    ["result"]=>
    int(30)
  }
  ...
}
*/

php-JsonRPC 官网

https://github.com/rryqszq4/php-JsonRPC

相关编程语言

MuPlayer 是一款跨平台、轻量级的音频播放解决方案,...
OS FLV 是一个 开源和可嵌入网页的flv播放器。 这个...
DewPlayer音乐播放器,样式很简单,而且很实用.播放器...
JW FLV MEDIA PLAYER是一个开源的在网页上使用的Fla...
Speakker 是一个基于 Web 浏览器的音乐播放器,只提...
Player Framework 是一个开源的支持 HTML5 的视频播...