PHP 인터페이스 Kraken\Channel\ChannelInterface

상속: extends Kraken\Event\EventEmitterInterface, extends Kraken\Loop\LoopAwareInterface
파일 보기 프로젝트 열기: kraken-php/framework 0 사용 예제들

공개 메소드들

메소드 설명
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 ( )