PHP Class PAMI\Client\Impl\ClientImpl

PHP Version 5
Author: Marcelo Gornstein ([email protected])
Inheritance: implements PAMI\Client\IClient
Afficher le fichier Open project: marcelog/pami Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( array $options ) Constructor.
close ( ) : void Closes the connection to ami.
open ( ) : void Opens a tcp connection to ami.
process ( ) Main processing loop. Also called from send(), you should call this in your own application in order to continue reading events and responses from ami.
registerEventListener ( mixed $listener, Closure | null $predicate = null ) : string Registers the given listener so it can receive events. Returns the generated id for this new listener. You can pass in a an IEventListener, a Closure, and an array containing the object and name of the method to invoke. Can specify an optional predicate to invoke before calling the callback.
send ( PAMI\Message\OutgoingMessage $message ) : PAMI\Message\Response\ResponseMessage Sends a message to ami.
setLogger ( Psr\Log\LoggerInterface $logger ) : void Sets the logger implementation.
unregisterEventListener ( string $listenerId ) : void Unregisters an event listener.

Méthodes protégées

Méthode Description
dispatch ( PAMI\Message\IncomingMessage $message ) : void Dispatchs the incoming message to a handler.
findResponse ( PAMI\Message\IncomingMessage $message ) : PAMI\Message\Response\ResponseMessage Tries to find an associated response for the given message.
getMessages ( ) : string[] Reads a complete message over the stream until EOM.
getRelated ( PAMI\Message\OutgoingMessage $message ) : PAMI\Message\IncomingMessage Returns a message (response) related to the given message. This uses the ActionID tag (key).

Private Methods

Méthode Description
messageToEvent ( string $msg ) : PAMI\Message\Event\EventMessage Returns a EventMessage from a raw string that came from asterisk.
messageToResponse ( string $msg ) : PAMI\Message\Response\ResponseMessage Returns a ResponseMessage from a raw string that came from asterisk.

Method Details

__construct() public méthode

Constructor.
public __construct ( array $options )
$options array Options for ami client.

close() public méthode

Closes the connection to ami.
public close ( ) : void
Résultat void

dispatch() protected méthode

Dispatchs the incoming message to a handler.
protected dispatch ( PAMI\Message\IncomingMessage $message ) : void
$message PAMI\Message\IncomingMessage Message to dispatch.
Résultat void

findResponse() protected méthode

Tries to find an associated response for the given message.
protected findResponse ( PAMI\Message\IncomingMessage $message ) : PAMI\Message\Response\ResponseMessage
$message PAMI\Message\IncomingMessage Message sent by asterisk.
Résultat PAMI\Message\Response\ResponseMessage

getMessages() protected méthode

Reads a complete message over the stream until EOM.
protected getMessages ( ) : string[]
Résultat string[]

getRelated() protected méthode

Returns a message (response) related to the given message. This uses the ActionID tag (key).
protected getRelated ( PAMI\Message\OutgoingMessage $message ) : PAMI\Message\IncomingMessage
$message PAMI\Message\OutgoingMessage
Résultat PAMI\Message\IncomingMessage

open() public méthode

Opens a tcp connection to ami.
public open ( ) : void
Résultat void

process() public méthode

Main processing loop. Also called from send(), you should call this in your own application in order to continue reading events and responses from ami.
public process ( )

registerEventListener() public méthode

Registers the given listener so it can receive events. Returns the generated id for this new listener. You can pass in a an IEventListener, a Closure, and an array containing the object and name of the method to invoke. Can specify an optional predicate to invoke before calling the callback.
public registerEventListener ( mixed $listener, Closure | null $predicate = null ) : string
$listener mixed
$predicate Closure | null
Résultat string

send() public méthode

Sends a message to ami.
See also: ClientImpl::send()
public send ( PAMI\Message\OutgoingMessage $message ) : PAMI\Message\Response\ResponseMessage
$message PAMI\Message\OutgoingMessage Message to send.
Résultat PAMI\Message\Response\ResponseMessage

setLogger() public méthode

Sets the logger implementation.
public setLogger ( Psr\Log\LoggerInterface $logger ) : void
$logger Psr\Log\LoggerInterface The PSR3-Logger
Résultat void

unregisterEventListener() public méthode

Unregisters an event listener.
public unregisterEventListener ( string $listenerId ) : void
$listenerId string The id returned by registerEventListener.
Résultat void