PHP code example of sanyateam / 3y-jsonrpc-client

1. Go to this page and download the library: Download sanyateam/3y-jsonrpc-client library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sanyateam / 3y-jsonrpc-client example snippets

`
# Notice
$res = RpcClient::instance(['tcp://localhost:5252'])->call(
    'Server.UserServer.getUser',
    ['call' => 'Server.UserServer.getUser']
);

# request
$res = RpcClient::instance(['tcp://localhost:5252'])->call(
    'Server.UserServer.getUser',
    ['call' => 'Server.UserServer.getUser'],
    RpcClient::uuid()
);
`
# request
try {
    [$key, $res] = $rpc->asyncNoticeSend(
        'Test.Test.demo',
        ['async' => 'notice_send'],
        true
    );

    # 如果开启调用方式唯一执行,以下会抛出一个MethodAlreadyException异常
    [$key, $res] = $rpc->asyncNoticeSend(
        'Test.Test.demo',
        ['async' => 'notice_send'],
        true
    );
    
}catch(\JsonRpc\Exception\MethodAlreadyException $methodAlreadyException){

}