PHP Класс PAMI\Client\Impl\ClientImpl

PHP Version 5
Автор: Marcelo Gornstein ([email protected])
Наследование: implements PAMI\Client\IClient
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
__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.

Защищенные методы

Метод Описание
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).

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

Метод Описание
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.

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

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

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

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

Closes the connection to ami.
public close ( ) : void
Результат void

dispatch() защищенный Метод

Dispatchs the incoming message to a handler.
protected dispatch ( PAMI\Message\IncomingMessage $message ) : void
$message PAMI\Message\IncomingMessage Message to dispatch.
Результат void

findResponse() защищенный Метод

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.
Результат PAMI\Message\Response\ResponseMessage

getMessages() защищенный Метод

Reads a complete message over the stream until EOM.
protected getMessages ( ) : string[]
Результат string[]

getRelated() защищенный Метод

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
Результат PAMI\Message\IncomingMessage

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

Opens a tcp connection to ami.
public open ( ) : void
Результат void

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.
public process ( )

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

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

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

Sends a message to ami.
См. также: ClientImpl::send()
public send ( PAMI\Message\OutgoingMessage $message ) : PAMI\Message\Response\ResponseMessage
$message PAMI\Message\OutgoingMessage Message to send.
Результат PAMI\Message\Response\ResponseMessage

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

Sets the logger implementation.
public setLogger ( Psr\Log\LoggerInterface $logger ) : void
$logger Psr\Log\LoggerInterface The PSR3-Logger
Результат void

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

Unregisters an event listener.
public unregisterEventListener ( string $listenerId ) : void
$listenerId string The id returned by registerEventListener.
Результат void