PHP Class PHPDaemon\Network\Pool

Author: Vasily Zorin ([email protected])
Inheritance: extends PHPDaemon\Structures\ObjectStorage, use trait PHPDaemon\Traits\EventLoopContainer
Datei anzeigen Open project: kakserpom/phpdaemon Class Usage Examples

Public Properties

Property Type Description
$appInstance Application instance object
$config Configuration
$connectionClass Default connection class
$maxAllowedPacket Max allowed packet
$maxConcurrency Max concurrency
$name Name

Protected Properties

Property Type Description
$enabled Is enabled?
$finished Is finished?
$instances Instances storage
$overload Is overloaded?

Public Methods

Method Description
__construct ( array $config = [], boolean $init = true ) Constructor
attach ( object $conn, mixed $inf = null ) : void Attach Connection
connect ( string $url, callback $cb, string $class = null ) : integer Establish a connection with remote peer
detach ( object $conn ) : void Detach Connection
disable ( ) : void Disable all events of sockets
enable ( ) : void Enable socket events
finish ( $graceful = false ) : boolean Finishes ConnectionPool
getInstance ( string $arg = '', boolean $spawn = true ) : this Returns instance object
onConfigUpdated ( ) : void Called when worker is going to update configuration
onReady ( ) : void Called when the worker is ready to go
onShutdown ( boolean $graceful = false ) : boolean Called when application instance is going to shutdown
setConnectionClass ( string $class ) : void Sets default connection class

Protected Methods

Method Description
applyConfig ( ) : void Applies config
getConfigDefaults ( ) : boolean Setting default config options
init ( ) : void Init
onDisable ( ) : void Called when ConnectionPool is now disabled
onEnable ( ) : void Called when ConnectionPool is now enabled
onFinish ( ) : void Called when ConnectionPool is finished

Method Details

__construct() public method

Constructor
public __construct ( array $config = [], boolean $init = true )
$config array Config variables
$init boolean

applyConfig() protected method

Applies config
protected applyConfig ( ) : void
return void

attach() public method

Attach Connection
public attach ( object $conn, mixed $inf = null ) : void
$conn object Connection
$inf mixed Info
return void

connect() public method

Establish a connection with remote peer
public connect ( string $url, callback $cb, string $class = null ) : integer
$url string URL
$cb callback Callback
$class string Optional. Connection class name
return integer Connection's ID. Boolean false when failed

detach() public method

Detach Connection
public detach ( object $conn ) : void
$conn object Connection
return void

disable() public method

Disable all events of sockets
public disable ( ) : void
return void

enable() public method

Enable socket events
public enable ( ) : void
return void

finish() public method

Finishes ConnectionPool
public finish ( $graceful = false ) : boolean
return boolean Success

getConfigDefaults() protected method

Setting default config options
protected getConfigDefaults ( ) : boolean
return boolean

getInstance() public static method

Returns instance object
public static getInstance ( string $arg = '', boolean $spawn = true ) : this
$arg string name / array config / ConfigSection
$spawn boolean Spawn? Default is true
return this

init() protected method

Init
protected init ( ) : void
return void

onConfigUpdated() public method

Called when worker is going to update configuration
public onConfigUpdated ( ) : void
return void

onDisable() protected method

Called when ConnectionPool is now disabled
protected onDisable ( ) : void
return void

onEnable() protected method

Called when ConnectionPool is now enabled
protected onEnable ( ) : void
return void

onFinish() protected method

Called when ConnectionPool is finished
protected onFinish ( ) : void
return void

onReady() public method

Called when the worker is ready to go
public onReady ( ) : void
return void

onShutdown() public method

Called when application instance is going to shutdown
public onShutdown ( boolean $graceful = false ) : boolean
$graceful boolean
return boolean Ready to shutdown?

setConnectionClass() public method

Sets default connection class
public setConnectionClass ( string $class ) : void
$class string Connection class name
return void

Property Details

$appInstance public_oe property

Application instance object
public $appInstance

$config public_oe property

Configuration
public $config

$connectionClass public_oe property

Default connection class
public $connectionClass

$enabled protected_oe property

Is enabled?
protected $enabled

$finished protected_oe property

Is finished?
protected $finished

$instances protected_oe static_oe property

Instances storage
protected static $instances

$maxAllowedPacket public_oe property

Max allowed packet
public $maxAllowedPacket

$maxConcurrency public_oe property

Max concurrency
public $maxConcurrency

$name public_oe property

Name
public $name

$overload protected_oe property

Is overloaded?
protected $overload