PHP Class PHPDaemon\Servers\WebSocket\Connection

Inheritance: extends PHPDaemon\Network\Connection, use trait PHPDaemon\Traits\DeferredEventHandlers, use trait PHPDaemon\Traits\Sessions
Datei anzeigen Open project: kakserpom/phpdaemon Class Usage Examples

Public Properties

Property Type Description
$cookie _COOKIE
$get _GET
$hvaltr Replacement pairs for processing some header values in parse_str()
$server _SERVER

Protected Properties

Property Type Description
$EOL
$contentLength Content length from header() method
$cookieNum Number of outgoing cookie-headers
$currentHeader
$extensions
$extensionsCleanRegex
$handshaked
$headers
$headers_sent
$policyReqNotFound
$route
$running Is this connection running right now?
$timeout Timeout
$writeReady

Public Methods

Method Description
badRequest ( ) : void Send Bad request
getFrameType ( $type ) : integer Get real frame type identificator
gracefulShutdown ( ) : boolean Called when the worker is going to shutdown.
handleException ( Exception $e ) : boolean Uncaught exception handler
handshake ( ) : boolean Called when we're going to handshake.
header ( string $s, boolean $replace = true, boolean $code = false ) : boolean Send the header
onFinish ( ) : void Event of Connection.
onFrame ( string $data, string $type ) : boolean Called when new frame received.
onInheritance ( $conn )
onInheritanceFromRequest ( object $req ) : void Called when connection is inherited from HTTP request
onReady ( ) : void Called when the stream is handshaked (at low-level), and peer is ready to recv. data
sendFrame ( string $data, string $type = null, callable $cb = null ) : boolean Sends a frame.
status ( integer $code = 200 ) : boolean Send HTTP-status

Protected Methods

Method Description
handshakeAfter ( )
httpProcessHeaders ( ) : boolean Process headers
httpReadFirstline ( ) : boolean | null Read first line of HTTP request
httpReadHeaders ( ) : boolean | null Read headers line-by-line
onRead ( ) : void Called when new data received.
switchToProtocol ( $proto )

Method Details

badRequest() public method

Send Bad request
public badRequest ( ) : void
return void

getFrameType() public method

Get real frame type identificator
public getFrameType ( $type ) : integer
$type
return integer

gracefulShutdown() public method

Called when the worker is going to shutdown.
public gracefulShutdown ( ) : boolean
return boolean Ready to shutdown ?

handleException() public method

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

handshake() public method

Called when we're going to handshake.
public handshake ( ) : boolean
return boolean Handshake status

handshakeAfter() protected method

protected handshakeAfter ( )

header() public method

Send the header
public header ( string $s, boolean $replace = true, boolean $code = false ) : boolean
$s string Header. Example: 'Location: http://php.net/'
$replace boolean Optional. Replace?
$code boolean Optional. HTTP response code
return boolean Success

httpProcessHeaders() protected method

Process headers
protected httpProcessHeaders ( ) : boolean
return boolean

httpReadFirstline() protected method

Read first line of HTTP request
protected httpReadFirstline ( ) : boolean | null
return boolean | null Success

httpReadHeaders() protected method

Read headers line-by-line
protected httpReadHeaders ( ) : boolean | null
return boolean | null Success

onFinish() public method

Event of Connection.
public onFinish ( ) : void
return void

onFrame() public method

Called when new frame received.
public onFrame ( string $data, string $type ) : boolean
$data string Frame's data.
$type string Frame's type ("STRING" OR "BINARY").
return boolean Success.

onInheritance() public method

public onInheritance ( $conn )

onInheritanceFromRequest() public method

Called when connection is inherited from HTTP request
public onInheritanceFromRequest ( object $req ) : void
$req object
return void

onRead() protected method

Called when new data received.
protected onRead ( ) : void
return void

onReady() public method

Called when the stream is handshaked (at low-level), and peer is ready to recv. data
public onReady ( ) : void
return void

sendFrame() public method

Sends a frame.
public sendFrame ( string $data, string $type = null, callable $cb = null ) : boolean
$data string Frame's data.
$type string Frame's type. ("STRING" OR "BINARY")
$cb callable Optional. Callback called when the frame is received by client.
return boolean Success.

status() public method

Send HTTP-status
public status ( integer $code = 200 ) : boolean
$code integer Code
return boolean Success

switchToProtocol() protected method

protected switchToProtocol ( $proto )

Property Details

$EOL protected_oe property

protected $EOL

$contentLength protected_oe property

Content length from header() method
protected $contentLength

$cookieNum protected_oe property

Number of outgoing cookie-headers
protected $cookieNum

$currentHeader protected_oe property

protected $currentHeader

$extensions protected_oe property

protected $extensions

$extensionsCleanRegex protected_oe property

protected $extensionsCleanRegex

$get public_oe property

_GET
public $get

$handshaked protected_oe property

protected $handshaked

$headers protected_oe property

protected $headers

$headers_sent protected_oe property

protected $headers_sent

$hvaltr public_oe static_oe property

Replacement pairs for processing some header values in parse_str()
public static $hvaltr

$policyReqNotFound protected_oe property

protected $policyReqNotFound

$route protected_oe property

protected $route

$running protected_oe property

Is this connection running right now?
protected $running

$server public_oe property

_SERVER
public $server

$timeout protected_oe property

Timeout
protected $timeout

$writeReady protected_oe property

protected $writeReady