示例#1
0
 /**
  * 初始化
  */
 private function _init()
 {
     $phprpcPath = LIB_PATH . '/phprpc/phprpc_client.php';
     if (!file_exists($phprpcPath)) {
         throw new Error('phprpc libs not exist');
     }
     include $phprpcPath;
     $this->_phpRpc = new PHPRPC_Client();
     $this->_phpRpc->setProxy(null);
     //设置代理
     $this->_phpRpc->setEncryptMode(0);
     $this->_phpRpc->setCharset('UTF-8');
     $this->_phpRpc->setTimeout(10);
 }
示例#2
0
<?php 
include "phprpc_client.php";
$client = new PHPRPC_Client('http://129.0.0.1/work/obsidian/libs/phprpc/server.php');
$client->setTimeout(5);
$client->setEncryptMode(3);
try {
    $out = $client->HelloWorld();
    echo $out;
} catch (Exception $e) {
    echo 'Caught exception: ', $e->getMessage(), "\n";
}
示例#3
0
#!/usr/bin/env php
<?php 
if ($argc < 2) {
    echo "Usage: {$argv['0']} <url> [POST data]\n";
    die;
}
$url = $argv[1];
$params = array();
if (isset($argv[2])) {
    parse_str($argv[2], $params);
}
require_once dirname(__FILE__) . '/phprpc/phprpc_client.php';
$client = new PHPRPC_Client();
$client->setProxy(NULL);
$client->useService($url);
$client->setKeyLength(1000);
$client->setEncryptMode(3);
$client->setCharset('UTF-8');
$client->setTimeout(10);
var_dump($client->response(json_encode($params)));
示例#4
0
 public function actionTest()
 {
     $serverList = $this->_getGlobalData('gameser_list');
     $server = $serverList[$_REQUEST['server_id']]['server_url'] . 'rpc/user';
     $phprpcPath = LIB_PATH . '/phprpc/phprpc_client.php';
     if (!file_exists($phprpcPath)) {
         throw new Error('phprpc libs not exist');
     }
     include_once $phprpcPath;
     $phpRpc = new PHPRPC_Client();
     $phpRpc->useService($server);
     $phpRpc->setProxy(null);
     //设置代理
     $phpRpc->setEncryptMode(0);
     $phpRpc->setCharset('UTF-8');
     $phpRpc->setTimeout(10);
     $phpRpc->setPrivateKey('test');
     $dataList = $phpRpc->getInfo('wcj');
     print_r($dataList);
 }