forked from yiliaofan/thrift-rpc-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.php
27 lines (22 loc) · 890 Bytes
/
client.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
// 引入客户端文件
require_once __DIR__ . "/Thrift/ClassLoader/ThriftClassLoader.php";
use Thrift\ClassLoader\ThriftClassLoader;
use Thrift\Protocol\TBinaryProtocol;
use Thrift\Transport\TSocket;
use Thrift\Transport\TFramedTransport;
$loader = new ThriftClassLoader();
$loader->registerNamespace('Thrift', __DIR__);
$loader->registerNamespace('Swoole', __DIR__);
$loader->registerNamespace('Services', __DIR__);
$loader->registerDefinition('Services', __DIR__);
$loader->register();
$socket = new TSocket("127.0.0.1", 8091);
$transport = new TFramedTransport($socket);
$protocol = new TBinaryProtocol($transport);
$transport->open();
$client = new Services\HelloSwoole\HelloSwooleClient($protocol);
$message = new Services\HelloSwoole\Message(array('send_uid' => 350749960, 'name' => 'rango'));
$ret = $client->sendMessage($message);
var_dump($ret);
$transport->close();