Nats\Connection::request PHP Method

request() public method

Request does a request and executes a callback with the response.
public request ( string $subject, string $payload, mixed $callback, integer $wait = 1 ) : void
$subject string Message topic.
$payload string Message data.
$callback mixed Closure to be executed as callback.
$wait integer Number of messages to wait for.
return void
    public function request($subject, $payload, $callback, $wait = 1)
    {
        $inbox = uniqid('_INBOX.');
        $this->subscribe($inbox, $callback);
        $msg = 'PUB ' . $subject . ' ' . $inbox . ' ' . strlen($payload);
        $this->send($msg . "\r\n" . $payload);
        $this->pubs += 1;
        $this->wait($wait);
    }