MAKS\AmqpAgent\RPC\ClientEndpoint
A class specialized in requesting. Implementing only the methods needed for a client.
Example:
```
$clientEndpoint = new ClientEndpoint();
$clientEndpoint->on('some.event', function () { ... });
$clientEndpoint->connect();
$clientEndpoint->request('Message Body', 'queue.name');
$clientEndpoint->disconnect();
```
Synopsis
- // Inherited members from AbstractEndpoint
- protected $connectionOptions;
- protected $queueName;
- protected bool $connected;
- protected AMQPStreamConnection $connection;
- protected AMQPChannel $channel;
- protected $requestBody;
- protected $requestQueue;
- protected $responseBody;
- protected $responseQueue;
- protected $correlationId;
- // methods
- public ClientEndpoint connect()
- public string request()
- public string call()
- protected void onResponse()
- protected string callback()
- // Inherited methods from AbstractEndpoint
- public void __construct()
- public void __destruct()
- public AbstractEndpoint connect()
- public void disconnect()
- public bool isConnected()
- public AMQPStreamConnection getConnection()
- public final float ping()
- public final AbstractEndpoint on()
- protected abstract string callback()
- // Inherited methods from MagicMethodsExceptionsTrait
- public void __get()
- public void __set()
- public mixed __call()
- public static mixed __callStatic()
- // Inherited methods from EventTrait
- protected static void trigger()
- protected static void bind()
- public static array getEvents()
Hierarchy
Coverage
| Methods | 100% | 5 / 5 | 
| Lines | 100% | 56 / 56 | 
Members
protected
- $channel
                —
                PhpAmqpLib\Channel\AMQPChannel
 The endpoint channel.
- $connected
                —
                MAKS\AmqpAgent\RPC\bool
 Whether the endpoint is connected to RabbitMQ server or not.
- $connection
                —
                PhpAmqpLib\Connection\AMQPStreamConnection
 The endpoint connection.
- $connectionOptions
                —
                array
 The connection options of the RPC endpoint.
- $correlationId
                —
                string
 Correlation ID of the last request/response.
- $events
                —
                array
 Here lives all bindings.
- $queueName
                —
                string
 The queue name of the RPC endpoint.
- $requestBody
                —
                string
 The request body.
- $requestQueue
                —
                string
 Requests conveyor.
- $responseBody
                —
                string
 The response body.
- $responseQueue
                —
                string
 Responses conveyor.
Methods
protected
- callback() — Returns the final response body.
- onResponse() — Validates the response.
public
- call() — Sends the passed request to the server using the passed queue.
- connect() — Opens a connection with RabbitMQ server.
- request() — Sends the passed request to the server using the passed queue.
Inherited from MAKS\AmqpAgent\RPC\AbstractEndpoint
protected
- callback() — Hook method to manipulate the message (request/response) when extending the class.
public
- connect() — Opens a connection with RabbitMQ server.
- disconnect() — Closes the connection with RabbitMQ server.
- getConnection() — Returns the connection used by the endpoint.
- isConnected() — Returns whether the endpoint is connected or not.
- on() — Hooking method based on events to manipulate the request/response during the endpoint/message life cycle.
- ping() — The time needed for the round-trip to RabbitMQ server in milliseconds.
Inherited from MAKS\AmqpAgent\Exception\MagicMethodsExceptionsTrait
public
- __call() — Throws an exception for calls to undefined methods.
- __callStatic() — Throws an exception for calls to undefined static methods.
- __get() — Throws an exception when trying to get a class member via public property assignment notation.
- __set() — Throws an exception when trying to set a class member via public property assignment notation.
Inherited from MAKS\AmqpAgent\Helper\EventTrait
protected
- bind() — Binds the passed function to the passed event.
- trigger() — Executes callbacks attached to the passed event with the passed arguments.
public
- getEvents() — Returns array of all registered events as an array `['event.name' => [$cb1, $cb2, ...]]`.
History
- 
            2021-01-12T21:10:22+00:00 (commit #dc55fd9)Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) Update client endpoint class * Update DocBlocks 
- 
            2021-01-12T21:10:21+00:00 (commit #d09424b)Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) Add strict types declaration * Add declare(strict_types=1) to all files * Fix file header DocBlock spacing of all files 
- 
            2020-12-03T22:53:33+00:00 (commit #c0218b5)Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) Update client endpoint class * Change an internal method call due to last code refactoring 
- 
            2020-12-03T21:47:07+00:00 (commit #6556fcd)Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) Update client endpoint class * Change some properties names to match parent class * Fix a coding style issue * Remove self return type from some method signatures * Add type castings to some unexpected return values from php-amqplib 
- 
            2020-12-02T23:00:24+00:00 (commit #c75c892)Author: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) / Commiter: Marwan Al-Soltany (MarwanAlsoltany@gmail.com) Add client endpoint class * Add ClientEndpoint.php