PHP Class PHPDaemon\Request\Generic

Inheritance: use trait PHPDaemon\Traits\ClassWatchdog, use trait PHPDaemon\Traits\StaticObjectWatchdog, use trait PHPDaemon\Traits\EventHandlers
Exibir arquivo Open project: kakserpom/phpdaemon Class Usage Examples

Public Properties

Property Type Description
$appInstance PHPDaemon\Core\AppInstance Related Application instance
$attrs StdCLass Attributes

Protected Properties

Property Type Description
$aborted boolean Is this request aborted?
$autoinit
$codepoint mixed Current code point
$ev object Event
$priority integer Priority
$running boolean Is this request running?
$shutdownFuncs array Registered shutdown functions
$sleepTime float Current sleep() time
$state State
$upstream object Upstream

Public Methods

Method Description
__construct ( AppInstance $appInstance, PHPDaemon\Request\IRequestUpstream $upstream, object $parent = null ) Constructor
__toString ( ) : string This magic method called when the object casts to string
abort ( ) : void Aborts the request
callInit ( )
checkIfReady ( ) : boolean Called to check if Request is ready
codepoint ( $p ) : boolean Helper for easy switching between several interruptable stages of request's execution
eventCall ( $arg ) : void Event handler of Request, called by Evtimer
finish ( $status, $zombie = false ) : void Finish the request
free ( ) : void Frees the request
getArray ( &$var, $filter = null ) : string Get array value from the given variable
getInteger ( &$var, $values = null ) : string Get integer value from the given variable
getMixed ( &$var ) : string Get string value from the given variable
getString ( &$var, $values = null ) : string Get string value from the given variable
handleException ( $e ) : boolean | null Uncaught exception handler
isAborted ( ) : boolean Is this request aborted?
isFinished ( ) : boolean Is this request finished?
isRunning ( ) : boolean Is this request running?
log ( string $msg ) : void Log
onAbort ( ) : void Called when the request aborted
onFinish ( ) : void Called when the request finished
onSleep ( ) : void Called when the request starts sleep
onWakeup ( ) : void Called when the request wakes up
onWrite ( ) : void Called when the connection is ready to accept new data
out ( string $s, boolean $flush = true ) : boolean | null Output some data
registerShutdownFunction ( callable $callback ) : void Adds new callback called before the request finished
setPriority ( $p ) : void Sets the priority
sleep ( integer $time, boolean $set = false ) : void Delays the request execution for the given number of seconds
terminate ( $s = null ) : void Throws terminating exception
unregisterShutdownFunction ( callable $callback ) : void Remove the given callback
wakeup ( ) : void Cancel current sleep

Protected Methods

Method Description
init ( ) : void Called when request constructs
postFinishHandler ( callable $cb = null ) : void Called after request finish
preinit ( $req ) : void Preparing before init
run ( ) : integer Called when request iterated.

Method Details

__construct() public method

Constructor
public __construct ( AppInstance $appInstance, PHPDaemon\Request\IRequestUpstream $upstream, object $parent = null )
$appInstance PHPDaemon\Core\AppInstance Parent AppInstance.
$upstream PHPDaemon\Request\IRequestUpstream Upstream.
$parent object Source request.

__toString() public method

This magic method called when the object casts to string
public __toString ( ) : string
return string Description

abort() public method

Aborts the request
public abort ( ) : void
return void

callInit() public method

public callInit ( )

checkIfReady() public method

Called to check if Request is ready
public checkIfReady ( ) : boolean
return boolean Ready?

codepoint() public method

Helper for easy switching between several interruptable stages of request's execution
public codepoint ( $p ) : boolean
return boolean Execute

eventCall() public method

Event handler of Request, called by Evtimer
public eventCall ( $arg ) : void
$arg
return void

finish() public method

Finish the request
public finish ( $status, $zombie = false ) : void
return void

free() public method

Frees the request
public free ( ) : void
return void

getArray() public static method

Get array value from the given variable
public static getArray ( &$var, $filter = null ) : string
return string Value.

getInteger() public static method

Get integer value from the given variable
public static getInteger ( &$var, $values = null ) : string
return string Value.

getMixed() public static method

Get string value from the given variable
public static getMixed ( &$var ) : string
return string Value.

getString() public static method

Get string value from the given variable
public static getString ( &$var, $values = null ) : string
return string Value.

handleException() public method

Uncaught exception handler
public handleException ( $e ) : boolean | null
$e
return boolean | null Handled?

init() protected method

Called when request constructs
protected init ( ) : void
return void

isAborted() public method

Is this request aborted?
public isAborted ( ) : boolean
return boolean

isFinished() public method

Is this request finished?
public isFinished ( ) : boolean
return boolean

isRunning() public method

Is this request running?
public isRunning ( ) : boolean
return boolean

log() public method

Log
public log ( string $msg ) : void
$msg string Message
return void

onAbort() public method

Called when the request aborted
public onAbort ( ) : void
return void

onFinish() public method

Called when the request finished
public onFinish ( ) : void
return void

onSleep() public method

Called when the request starts sleep
public onSleep ( ) : void
return void

onWakeup() public method

Called when the request wakes up
public onWakeup ( ) : void
return void

onWrite() public method

Called when the connection is ready to accept new data
public onWrite ( ) : void
return void

out() public method

Output some data
public out ( string $s, boolean $flush = true ) : boolean | null
$s string String to out
$flush boolean
return boolean | null Success

postFinishHandler() protected method

Called after request finish
protected postFinishHandler ( callable $cb = null ) : void
$cb callable
return void

preinit() protected method

Preparing before init
protected preinit ( $req ) : void
return void

registerShutdownFunction() public method

Adds new callback called before the request finished
public registerShutdownFunction ( callable $callback ) : void
$callback callable
return void

run() protected method

Called when request iterated.
protected run ( ) : integer
return integer Status.

setPriority() public method

Sets the priority
public setPriority ( $p ) : void
return void

sleep() public method

Delays the request execution for the given number of seconds
public sleep ( integer $time, boolean $set = false ) : void
$time integer Time to sleep in seconds
$set boolean Set this parameter to true when use call it outside of Request->run() or if you don't want to interrupt execution now
return void

terminate() public method

Throws terminating exception
public terminate ( $s = null ) : void
$s
return void

unregisterShutdownFunction() public method

Remove the given callback
public unregisterShutdownFunction ( callable $callback ) : void
$callback callable
return void

wakeup() public method

Cancel current sleep
public wakeup ( ) : void
return void

Property Details

$aborted protected_oe property

Is this request aborted?
protected bool $aborted
return boolean

$appInstance public_oe property

Related Application instance
public AppInstance,PHPDaemon\Core $appInstance
return PHPDaemon\Core\AppInstance

$attrs public_oe property

Attributes
public StdCLass $attrs
return StdCLass

$autoinit protected_oe property

protected $autoinit

$codepoint protected_oe property

Current code point
protected mixed $codepoint
return mixed

$ev protected_oe property

Event
protected object $ev
return object

$priority protected_oe property

Priority
protected int $priority
return integer

$running protected_oe property

Is this request running?
protected bool $running
return boolean

$shutdownFuncs protected_oe property

Registered shutdown functions
protected array $shutdownFuncs
return array

$sleepTime protected_oe property

Current sleep() time
protected float $sleepTime
return float

$state protected_oe property

State
protected $state

$upstream protected_oe property

Upstream
protected object $upstream
return object