PHP Интерфейс Kraken\Channel\ChannelInterface

Наследование: extends Kraken\Event\EventEmitterInterface, extends Kraken\Loop\LoopAwareInterface
Показать файл Открыть проект Примеры использования интерфейса

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

Метод Описание
createProtocol ( string | string[] | null $message = null ) : Kraken\Channel\Protocol\ProtocolInterface Put message into newly created protocol and return its wrapper.
filterConnected ( string | string[] $pattern ) : string[] Return array of all connected channels' IDs that matches pattern
getConnected ( ) : string[] Return array of all connected external channels' IDs.
getInput ( ) : Kraken\Channel\Router\RouterInterface | Kraken\Channel\Router\RouterCompositeInterface Return router used for input messages.
getModel ( ) : Kraken\Channel\ChannelModelInterface | null Return model which is being used by Channel.
getName ( ) : string Return Channel name.
getOutput ( ) : Kraken\Channel\Router\RouterInterface | Kraken\Channel\Router\RouterCompositeInterface Return router used for output messages.
getRouter ( ) : Kraken\Channel\Router\RouterCompositeInterface Return router which is being used by Channel.
isConnected ( string | string[] $name ) : boolean | bool[] Check if specific external channel is connected.
isStarted ( ) : boolean | bool[] Check if channel is started.
isStopped ( ) : boolean | bool[] Check if channel is stopped.
onConnect ( callable $handler ) : EventListener Attach connect event handler.
onDisconnect ( callable $handler ) : EventListener Attach disconnect event handler.
onInput ( callable $handler ) : EventListener Attach input event handler.
onOutput ( callable $handler ) : EventListener Attach output event handler.
onStart ( callable $handler ) : EventListener Attach start event handler.
onStop ( callable $handler ) : EventListener Attach stop event handler.
pull ( string $sender, Kraken\Channel\Protocol\ProtocolInterface $protocol ) Pull message from sender.
push ( string | string[] $name, string | string[] | Kraken\Channel\Protocol\ProtocolInterface $message, integer $flags = Channel::MODE_DEFAULT, callable $success = null, callable $failure = null, callable $cancel = null, float $timeout ) : RequestRecord | RequestRecord[] | null | null[] | boolean | bool[] Push one or multiple messages to one or more receivers.
pushAsync ( string | string[] $name, string | string[] | Kraken\Channel\Protocol\ProtocolInterface $message, integer $flags = Channel::MODE_DEFAULT ) : boolean | bool[] Push one or multiple asynchronous messages to one or more receivers.
pushRequest ( string | string[] $name, string | string[] | Kraken\Channel\Protocol\ProtocolInterface $message, integer $flags = Channel::MODE_DEFAULT, callable $success = null, callable $failure = null, callable $cancel = null, float $timeout ) : RequestRecord | RequestRecord[] | null | null[] Push one or multiple requests to one or more receivers.
receive ( string $sender, Kraken\Channel\Protocol\ProtocolInterface $protocol ) Receive message from sender.
send ( string | string[] $name, string | string[] | Kraken\Channel\Protocol\ProtocolInterface $message, integer $flags = Channel::MODE_DEFAULT, callable $success = null, callable $failure = null, callable $cancel = null, float $timeout ) : mixed | mixed[] Send one or multiple messages to one or more receivers.
sendAsync ( string | string[] $name, string | string[] | Kraken\Channel\Protocol\ProtocolInterface $message, integer $flags = Channel::MODE_DEFAULT ) : boolean | bool[] Send one or multiple asynchronous messages to one or more receivers.
sendRequest ( string | string[] $name, string | string[] | Kraken\Channel\Protocol\ProtocolInterface $message, integer $flags = Channel::MODE_DEFAULT, callable $success = null, callable $failure = null, callable $cancel = null, float $timeout ) : boolean | bool[] Send one or multiple requests to one or more receivers.
start ( ) Start channel.
stop ( ) Stop channel.

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

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

Put message into newly created protocol and return its wrapper.
public createProtocol ( string | string[] | null $message = null ) : Kraken\Channel\Protocol\ProtocolInterface
$message string | string[] | null
Результат Kraken\Channel\Protocol\ProtocolInterface

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

Return array of all connected channels' IDs that matches pattern
public filterConnected ( string | string[] $pattern ) : string[]
$pattern string | string[]
Результат string[]

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

Return array of all connected external channels' IDs.
public getConnected ( ) : string[]
Результат string[]

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

Throws ResourceUndefinedException if input router is not found.
public getInput ( ) : Kraken\Channel\Router\RouterInterface | Kraken\Channel\Router\RouterCompositeInterface
Результат Kraken\Channel\Router\RouterInterface | Kraken\Channel\Router\RouterCompositeInterface

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

Return model which is being used by Channel.
public getModel ( ) : Kraken\Channel\ChannelModelInterface | null
Результат Kraken\Channel\ChannelModelInterface | null

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

Return Channel name.
public getName ( ) : string
Результат string

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

Throws ResourceUndefinedException if output router is not found.
public getOutput ( ) : Kraken\Channel\Router\RouterInterface | Kraken\Channel\Router\RouterCompositeInterface
Результат Kraken\Channel\Router\RouterInterface | Kraken\Channel\Router\RouterCompositeInterface

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

Return router which is being used by Channel.
public getRouter ( ) : Kraken\Channel\Router\RouterCompositeInterface
Результат Kraken\Channel\Router\RouterCompositeInterface

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

Check if specific external channel is connected.
public isConnected ( string | string[] $name ) : boolean | bool[]
$name string | string[]
Результат boolean | bool[]

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

Check if channel is started.
public isStarted ( ) : boolean | bool[]
Результат boolean | bool[]

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

Check if channel is stopped.
public isStopped ( ) : boolean | bool[]
Результат boolean | bool[]

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

Attach connect event handler.
public onConnect ( callable $handler ) : EventListener
$handler callable
Результат Kraken\Event\EventListener

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

Attach disconnect event handler.
public onDisconnect ( callable $handler ) : EventListener
$handler callable
Результат Kraken\Event\EventListener

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

Attach input event handler.
public onInput ( callable $handler ) : EventListener
$handler callable
Результат Kraken\Event\EventListener

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

Attach output event handler.
public onOutput ( callable $handler ) : EventListener
$handler callable
Результат Kraken\Event\EventListener

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

Attach start event handler.
public onStart ( callable $handler ) : EventListener
$handler callable
Результат Kraken\Event\EventListener

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

Attach stop event handler.
public onStop ( callable $handler ) : EventListener
$handler callable
Результат Kraken\Event\EventListener

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

This method pulls message immediataly processing it without router usage.
public pull ( string $sender, Kraken\Channel\Protocol\ProtocolInterface $protocol )
$sender string
$protocol Kraken\Channel\Protocol\ProtocolInterface

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

In comparison to send() method skips routing mechanisms and tries to push message directly to receiver, therefore this method should be used with caution. This method will push multiple messages separately. If any of the callback handlers are set, then message(s) will be treated as Request(s) and Channel will asynchronously await response(s). On the other hand, if none are set, then message(s) will be send without creating handler making the process faster and better memory-optimized. However, in that case Channel will not be able to process any returned values. Timeout works only for requests and represents number of seconds after which handler will automatically cancel. Flags might be one of: Channel::MODE_STANDARD - sends message if both sender and receiver are online. Channel::MODE_BUFFER_OFFLINE - works in similar way as MODE_STANDARD, but also enables buffering messages in case that sender is offline. Channel::MODE_BUFFER_ONLINE - works in similar way as MODE_STANDARD, but also enables buffering messages in case that receiver is offline. Channel::MODE_BUFFER - sends message if both sender and receiver are online or buffers it if one of them is offline.
public push ( string | string[] $name, string | string[] | Kraken\Channel\Protocol\ProtocolInterface $message, integer $flags = Channel::MODE_DEFAULT, callable $success = null, callable $failure = null, callable $cancel = null, float $timeout ) : RequestRecord | RequestRecord[] | null | null[] | boolean | bool[]
$name string | string[]
$message string | string[] | Kraken\Channel\Protocol\ProtocolInterface
$flags integer
$success callable
$failure callable
$cancel callable
$timeout float
Результат Kraken\Channel\Record\RequestRecord | Kraken\Channel\Record\RequestRecord[] | null | null[] | boolean | bool[]

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

This method only enables pushing asynchronous messages. For more complex options use push() method.
См. также: ChannelInterface::push
public pushAsync ( string | string[] $name, string | string[] | Kraken\Channel\Protocol\ProtocolInterface $message, integer $flags = Channel::MODE_DEFAULT ) : boolean | bool[]
$name string | string[]
$message string | string[] | Kraken\Channel\Protocol\ProtocolInterface
$flags integer
Результат boolean | bool[]

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

This method only enables pushing requests. For more complex options use push() method.
См. также: ChannelInterface::push
public pushRequest ( string | string[] $name, string | string[] | Kraken\Channel\Protocol\ProtocolInterface $message, integer $flags = Channel::MODE_DEFAULT, callable $success = null, callable $failure = null, callable $cancel = null, float $timeout ) : RequestRecord | RequestRecord[] | null | null[]
$name string | string[]
$message string | string[] | Kraken\Channel\Protocol\ProtocolInterface
$flags integer
$success callable
$failure callable
$cancel callable
$timeout float
Результат Kraken\Channel\Record\RequestRecord | Kraken\Channel\Record\RequestRecord[] | null | null[]

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

This method uses Channel input router to validate the message and then process or do something else with it depending on router rules.
public receive ( string $sender, Kraken\Channel\Protocol\ProtocolInterface $protocol )
$sender string
$protocol Kraken\Channel\Protocol\ProtocolInterface

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

In comparison to push() method, this one sends messages first to output router that decides how to handle them. This method will send multiple messages separately. If any of the callback handlers are set, then message(s) will be treated as Request(s) and Channel will asynchronously await response(s). On the other hand, if none are set, then message(s) will be send without creating handler making the process faster and better memory-optimized. However, in that case Channel will not be able to process any returned values. Timeout works only for requests and represents number of seconds after which handler will automatically cancel. Flags might be one of: Channel::MODE_STANDARD - sends message if both sender and receiver are online. Channel::MODE_BUFFER_OFFLINE - works in similar way as MODE_STANDARD, but also enables buffering messages in case that sender is offline. Channel::MODE_BUFFER_ONLINE - works in similar way as MODE_STANDARD, but also enables buffering messages in case that receiver is offline. Channel::MODE_BUFFER - sends message if both sender and receiver are online or buffers it if one of them is offline.
См. также: ChannelInterface::sendAsync
См. также: ChannelInterface::sendRequest
public send ( string | string[] $name, string | string[] | Kraken\Channel\Protocol\ProtocolInterface $message, integer $flags = Channel::MODE_DEFAULT, callable $success = null, callable $failure = null, callable $cancel = null, float $timeout ) : mixed | mixed[]
$name string | string[]
$message string | string[] | Kraken\Channel\Protocol\ProtocolInterface
$flags integer
$success callable
$failure callable
$cancel callable
$timeout float
Результат mixed | mixed[]

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

This method only enables sending asynchronous messages. For more complex options use send() method.
См. также: ChannelInterface::send
public sendAsync ( string | string[] $name, string | string[] | Kraken\Channel\Protocol\ProtocolInterface $message, integer $flags = Channel::MODE_DEFAULT ) : boolean | bool[]
$name string | string[]
$message string | string[] | Kraken\Channel\Protocol\ProtocolInterface
$flags integer
Результат boolean | bool[]

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

This method only enables sending requests. For more complex options use send() method.
См. также: ChannelInterface::send
public sendRequest ( string | string[] $name, string | string[] | Kraken\Channel\Protocol\ProtocolInterface $message, integer $flags = Channel::MODE_DEFAULT, callable $success = null, callable $failure = null, callable $cancel = null, float $timeout ) : boolean | bool[]
$name string | string[]
$message string | string[] | Kraken\Channel\Protocol\ProtocolInterface
$flags integer
$success callable
$failure callable
$cancel callable
$timeout float
Результат boolean | bool[]

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

Start channel.
public start ( )

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

Stop channel.
public stop ( )