PHP Класс Nats\Connection

Показать файл Открыть проект

Открытые методы

Метод Описание
__construct ( ConnectionOptions $options = null ) Constructor.
close ( ) : void Close will close the connection to the server.
connect ( float $timeout = null ) : void Connect to server.
getSubscriptions ( ) : array Return subscriptions list.
isConnected ( ) : boolean Checks if the client is connected to a server.
ping ( ) : void Sends PING message.
pingsCount ( ) : integer Return the number of pings.
publish ( string $subject, string $payload = null ) : void Publish publishes the data argument to the given subject.
pubsCount ( ) : integer Return the number of messages published.
queueSubscribe ( string $subject, string $queue, Closure $callback ) : string Subscribes to an specific event given a subject and a queue.
reconnect ( ) : void Reconnects to the server.
reconnectsCount ( ) : integer Return the number of reconnects to the server.
request ( string $subject, string $payload, mixed $callback, integer $wait = 1 ) : void Request does a request and executes a callback with the response.
setChunkSize ( integer $chunkSize ) : void
setStreamTimeout ( float $seconds ) : boolean Set Stream Timeout.
streamSocket ( ) : resource
subscribe ( string $subject, Closure $callback ) : string Subscribes to an specific event given a subject.
subscriptionsCount ( ) : integer Return the number of subscriptions available.
unsubscribe ( string $sid ) : void Unsubscribe from a event given a subject.
wait ( integer $quantity ) : resource Waits for messages.

Приватные методы

Метод Описание
getStream ( string $address, float $timeout ) : resource Returns an stream socket to the desired server.
handleMSG ( string $line ) : void Handles MSG command.
handlePING ( ) : void Handles PING command.
receive ( integer $len = null ) : string Receives a message thought the stream.
send ( string $payload ) : void Sends data thought the stream.

Описание методов

__construct() публичный Метод

Constructor.
public __construct ( ConnectionOptions $options = null )
$options ConnectionOptions Connection options object.

close() публичный Метод

Close will close the connection to the server.
public close ( ) : void
Результат void

connect() публичный Метод

Connect to server.
public connect ( float $timeout = null ) : void
$timeout float Number of seconds until the connect() system call should timeout.
Результат void

getSubscriptions() публичный Метод

Return subscriptions list.
public getSubscriptions ( ) : array
Результат array list of subscription ids

isConnected() публичный Метод

Checks if the client is connected to a server.
public isConnected ( ) : boolean
Результат boolean

ping() публичный Метод

Sends PING message.
public ping ( ) : void
Результат void

pingsCount() публичный Метод

Return the number of pings.
public pingsCount ( ) : integer
Результат integer Number of pings

publish() публичный Метод

Publish publishes the data argument to the given subject.
public publish ( string $subject, string $payload = null ) : void
$subject string Message topic.
$payload string Message data.
Результат void

pubsCount() публичный Метод

Return the number of messages published.
public pubsCount ( ) : integer
Результат integer number of messages published

queueSubscribe() публичный Метод

Subscribes to an specific event given a subject and a queue.
public queueSubscribe ( string $subject, string $queue, Closure $callback ) : string
$subject string Message topic.
$queue string Queue name.
$callback Closure Closure to be executed as callback.
Результат string

reconnect() публичный Метод

Reconnects to the server.
public reconnect ( ) : void
Результат void

reconnectsCount() публичный Метод

Return the number of reconnects to the server.
public reconnectsCount ( ) : integer
Результат integer number of reconnects

request() публичный Метод

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.
Результат void

setChunkSize() публичный Метод

public setChunkSize ( integer $chunkSize ) : void
$chunkSize integer Set byte chunk len to read when reading from wire.
Результат void

setStreamTimeout() публичный Метод

Set Stream Timeout.
public setStreamTimeout ( float $seconds ) : boolean
$seconds float Before timeout on stream.
Результат boolean

streamSocket() публичный Метод

public streamSocket ( ) : resource
Результат resource

subscribe() публичный Метод

Subscribes to an specific event given a subject.
public subscribe ( string $subject, Closure $callback ) : string
$subject string Message topic.
$callback Closure Closure to be executed as callback.
Результат string

subscriptionsCount() публичный Метод

Return the number of subscriptions available.
public subscriptionsCount ( ) : integer
Результат integer number of subscription

unsubscribe() публичный Метод

Unsubscribe from a event given a subject.
public unsubscribe ( string $sid ) : void
$sid string Subscription ID.
Результат void

wait() публичный Метод

Waits for messages.
public wait ( integer $quantity ) : resource
$quantity integer Number of messages to wait for.
Результат resource $connection Connection object