PHP Class Vinelab\Minion\Client

Author: Abed Halawi ([email protected])
Inheritance: extends Thruway\Peer\Client
Show file Open project: vinelab/minion Class Usage Examples

Protected Properties

Property Type Description
$delegateProvider Provider The delegate provider instance.
$topicPrefix string The prefix to use when generating topics/.

Public Methods

Method Description
__construct ( string $realm, array $providers ) Constructor.
call ( string $procedure, array $arguments = null, array $argumentsKw = null, array $options = null ) : Promise Call a registered procedure.
getDelegateProvider ( ) : Provider Get the delegate provider of this client.
getProviders ( ) : array Get the registered providers.
getTopicPrefix ( ) : string Get the topic prefix.
onSessionStart ( AbstractSession $session, Thruway\Transport\TransportInterface $transport ) Called when the server session has started which will call all the providers so that they perform whatever they have to do.
publish ( string $topic, array | mixed $arguments = null, array | mixed $argumentsKw = null, array $options = null ) : Promise Publish to a topic with the given data.
register ( string $topic, Closure $callback, array $options = null, boolean $isFunction = false ) : Promise Register a RPC.
setDelegateProvider ( Provider $provider ) Set the delegate provider of this client.
setTopicPrefix ( string $prefix ) Set the topic prefix.
start ( $debug = false, boolean $startLoop = true ) Start the transport.
subscribe ( string $topic, string | Closur\Closure $callback, array $options = null, boolean $isFunction = false ) : Promise Subscribe to a topic and specify a callback for it.
wrapWithProxy ( mixed $callback, boolean $isFunction = false ) : Closure Wrap the given callback with a proxy Closure.

Protected Methods

Method Description
prepareTopic ( string $topic ) : string Prepare the topic by prefixing it with @property $prefix as a convenience for having to manually prefix every topic.

Private Methods

Method Description
bootProviders ( ) Boot up the registered providers by calling their boot() method.

Method Details

__construct() public method

Constructor.
public __construct ( string $realm, array $providers )
$realm string
$providers array

call() public method

Call a registered procedure.
public call ( string $procedure, array $arguments = null, array $argumentsKw = null, array $options = null ) : Promise
$procedure string
$arguments array
$argumentsKw array
$options array
return React\Promise\Promise

getDelegateProvider() public method

Get the delegate provider of this client.
public getDelegateProvider ( ) : Provider
return Provider

getProviders() public method

Get the registered providers.
public getProviders ( ) : array
return array

getTopicPrefix() public method

Get the topic prefix.
public getTopicPrefix ( ) : string
return string

onSessionStart() public method

Called when the server session has started which will call all the providers so that they perform whatever they have to do.
public onSessionStart ( AbstractSession $session, Thruway\Transport\TransportInterface $transport )
$session Thruway\AbstractSession
$transport Thruway\Transport\TransportInterface

prepareTopic() protected method

Prepare the topic by prefixing it with @property $prefix as a convenience for having to manually prefix every topic.
protected prepareTopic ( string $topic ) : string
$topic string
return string

publish() public method

Publish to a topic with the given data.
public publish ( string $topic, array | mixed $arguments = null, array | mixed $argumentsKw = null, array $options = null ) : Promise
$topic string
$arguments array | mixed
$argumentsKw array | mixed
$options array
return React\Promise\Promise

register() public method

Register a RPC.
public register ( string $topic, Closure $callback, array $options = null, boolean $isFunction = false ) : Promise
$topic string
$callback Closure
$options array
$isFunction boolean
return React\Promise\Promise

setDelegateProvider() public method

Set the delegate provider of this client.
public setDelegateProvider ( Provider $provider )
$provider Provider

setTopicPrefix() public method

Set the topic prefix.
public setTopicPrefix ( string $prefix )
$prefix string

start() public method

Start the transport.
public start ( $debug = false, boolean $startLoop = true )
$startLoop boolean

subscribe() public method

Subscribe to a topic and specify a callback for it.
See also: Thruway\ClientSession::subscribe
public subscribe ( string $topic, string | Closur\Closure $callback, array $options = null, boolean $isFunction = false ) : Promise
$topic string The topic name.
$callback string | Closur\Closure The callable to be called when the topic received a publish.
$options array Will be passed straight to thruway @see \Thruway\ClientSession::subscribe
$isFunction boolean Specify whether you're passing in a function from a different scope, Set this to TRUE to avoid calling the passed callable from this provider's scope.
return React\Promise\Promise

wrapWithProxy() public method

The reason we use this is to be able to format the given $data into a Dictionary which makes it safer to work with them.
public wrapWithProxy ( mixed $callback, boolean $isFunction = false ) : Closure
$callback mixed
$isFunction boolean
return Closure

Property Details

$delegateProvider protected property

The delegate provider instance.
protected Provider,Vinelab\Minion $delegateProvider
return Provider

$topicPrefix protected property

The prefix to use when generating topics/.
protected string $topicPrefix
return string