PHP Class Nats\Connection

Afficher le fichier Open project: repejota/phpnats

Méthodes publiques

Méthode Description
__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.

Private Methods

Méthode Description
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.

Method Details

__construct() public méthode

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

close() public méthode

Close will close the connection to the server.
public close ( ) : void
Résultat void

connect() public méthode

Connect to server.
public connect ( float $timeout = null ) : void
$timeout float Number of seconds until the connect() system call should timeout.
Résultat void

getSubscriptions() public méthode

Return subscriptions list.
public getSubscriptions ( ) : array
Résultat array list of subscription ids

isConnected() public méthode

Checks if the client is connected to a server.
public isConnected ( ) : boolean
Résultat boolean

ping() public méthode

Sends PING message.
public ping ( ) : void
Résultat void

pingsCount() public méthode

Return the number of pings.
public pingsCount ( ) : integer
Résultat integer Number of pings

publish() public méthode

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.
Résultat void

pubsCount() public méthode

Return the number of messages published.
public pubsCount ( ) : integer
Résultat integer number of messages published

queueSubscribe() public méthode

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.
Résultat string

reconnect() public méthode

Reconnects to the server.
public reconnect ( ) : void
Résultat void

reconnectsCount() public méthode

Return the number of reconnects to the server.
public reconnectsCount ( ) : integer
Résultat integer number of reconnects

request() public méthode

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.
Résultat void

setChunkSize() public méthode

public setChunkSize ( integer $chunkSize ) : void
$chunkSize integer Set byte chunk len to read when reading from wire.
Résultat void

setStreamTimeout() public méthode

Set Stream Timeout.
public setStreamTimeout ( float $seconds ) : boolean
$seconds float Before timeout on stream.
Résultat boolean

streamSocket() public méthode

public streamSocket ( ) : resource
Résultat resource

subscribe() public méthode

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.
Résultat string

subscriptionsCount() public méthode

Return the number of subscriptions available.
public subscriptionsCount ( ) : integer
Résultat integer number of subscription

unsubscribe() public méthode

Unsubscribe from a event given a subject.
public unsubscribe ( string $sid ) : void
$sid string Subscription ID.
Résultat void

wait() public méthode

Waits for messages.
public wait ( integer $quantity ) : resource
$quantity integer Number of messages to wait for.
Résultat resource $connection Connection object