The Yar_Client class

(No version information available, might only be in Git)

Introduzione

The client side of the Yar RPC framework. A client is bound to a single service address; invoking any undefined method on it issues a remote call with that method name and the given arguments.

Sommario della classe

class Yar_Client {
/* Proprietà */
protected int $_protocol;
protected string $_uri;
protected ?array $_options;
protected bool $_running;
/* Metodi */
final public function __construct(string $uri, ?array $options = null)
public function call(string $method, array $arguments): mixed
public function getOpt(int $name): mixed
public function setOpt(int $name, mixed $value): Yar_Client|bool
}

Proprietà

_protocol

Read-only. The protocol derived from the service address: one of YAR_CLIENT_PROTOCOL_HTTP, YAR_CLIENT_PROTOCOL_TCP or YAR_CLIENT_PROTOCOL_UNIX.

_uri

Read-only. The service address the client was created with.

_options

Read-only. An array of the options set on this client, keyed by the YAR_OPT_* constants, or null if none were set.

_running

Read-only. Whether a call issued by this client is currently in progress.

Indice dei contenuti

add a note

User Contributed Notes 1 note

up
-1
porschegt23 at foxmail dot com
10 years ago
A simple example on here:

server.php
<?php
class API {
   
    public function api($parameter = "", $option = "foo") {
          return $this->client_can_not_see($parameter);
    }
 
 
    public function doAdd($a = 0, $b = 0) {
          return $a+$b;
    }
   
    protected function client_can_not_see( $name ) {
      return "你好$name~";
    }
}

$service = new Yar_Server ( new API () );
$service->handle ();
?>
client.php
<?php
  $client = new Yar_Client("http://host/server.php");
  $result = $client->api("parameter");
  echo $result.'<hr>';
  echo $client->doAdd(10, 20);
?>