-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.php
31 lines (26 loc) · 897 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
27
28
29
30
31
<?php
error_reporting(E_ALL);
require_once __DIR__.'/vendor/autoload.php';
require_once __DIR__.'/gen-php/Sample/Calc/CalculatorIf.php';
require_once __DIR__.'/gen-php/Sample/Calc/CalculatorClient.php';
require_once __DIR__.'/gen-php/Sample/Calc/Calculator_add_args.php';
require_once __DIR__.'/gen-php/Sample/Calc/Calculator_add_result.php';
use Thrift\Transport\TSocket;
use Thrift\Transport\THttpClient;
use Thrift\Transport\TBufferedTransport;
use Thrift\Exception\TException;
use Thrift\Protocol\TBinaryProtocol;
final class Client
{
public static function main()
{
$transport = new TBufferedTransport(new TSocket('localhost', 9091), 1024, 1024);;
$protocol = new TBinaryProtocol($transport, false, false);
$client = new \Sample\Calc\CalculatorClient($protocol);
$transport->open();
$sum = $client->add(1,1);
print "1+1=$sum\n";
$transport->close();
}
}
Client::main();