Documentation

Connection
in package
implements LoggerAwareInterface, Stringable uses SendMethodsTrait, StringableTrait

WebSocket\Connection class.

A client/server connection, wrapping socket stream.

Table of Contents

Interfaces

LoggerAwareInterface
Describes a logger-aware instance.
Stringable

Properties

$closed  : bool
$frameSize  : int
$handshakeRequest  : Request|null
$handshakeResponse  : Response|null
$httpHandler  : HttpHandler
$localName  : string
$logger  : LoggerInterface
$messageHandler  : MessageHandler
$meta  : array<string|int, mixed>
$middlewareHandler  : MiddlewareHandler
$remoteName  : string
$stream  : SocketStream
$timeout  : int

Methods

__construct()  : mixed
__destruct()  : mixed
__toString()  : string
addMiddleware()  : self
Add a middleware.
binary()  : Binary
Send binary message.
close()  : Close
Tell the socket to close.
closeRead()  : self
Close connection stream reading.
closeWrite()  : self
Close connection stream writing.
disconnect()  : self
Close connection stream.
getFrameSize()  : int
Get frame size.
getHandshakeRequest()  : Request|null
getHandshakeResponse()  : Response|null
getMeta()  : mixed
Get meta value on connection.
getName()  : string|null
Get name of local socket, or null if not connected.
getRemoteName()  : string|null
Get name of remote socket, or null if not connected.
getTimeout()  : int
Get timeout.
isConnected()  : bool
If connected to stream.
isReadable()  : bool
If connection is readable.
isWritable()  : bool
If connection is writable.
ping()  : Ping
Send ping.
pong()  : Pong
Send unsolicited pong.
pullHttp()  : Message
pullMessage()  : Message
pushHttp()  : Message
pushMessage()  : Message
send()  : Message
setFrameSize()  : self
Set frame size.
setHandshakeRequest()  : self
setHandshakeResponse()  : self
setLogger()  : void
Set logger.
setMeta()  : void
Set meta value on connection.
setTimeout()  : self
Set time out on connection.
text()  : Text
Send text message.
tick()  : void
Tick operation on connection.
stringable()  : string
throwException()  : never

Properties

$meta

private array<string|int, mixed> $meta = []

Methods

__construct()

public __construct(SocketStream $stream, bool $pushMasked, bool $pullMaskedRequired[, bool $ssl = false ]) : mixed
Parameters
$stream : SocketStream
$pushMasked : bool
$pullMaskedRequired : bool
$ssl : bool = false

__toString()

public __toString() : string
Return values
string

binary()

Send binary message.

public binary(string $message) : Binary
Parameters
$message : string

Content as binary string.

Return values
Binary

instance

close()

Tell the socket to close.

public close([int $status = 1000 ][, string $message = 'ttfn' ]) : Close
Parameters
$status : int = 1000

http://tools.ietf.org/html/rfc6455#section-7.4

$message : string = 'ttfn'

A closing message, max 125 bytes.

Return values
Close

instance

closeRead()

Close connection stream reading.

public closeRead() : self
Return values
self

.

closeWrite()

Close connection stream writing.

public closeWrite() : self
Return values
self

.

disconnect()

Close connection stream.

public disconnect() : self
Return values
self

.

getFrameSize()

Get frame size.

public getFrameSize() : int
Return values
int

Frame size in bytes

getMeta()

Get meta value on connection.

public getMeta(string $key) : mixed
Parameters
$key : string

Meta key

Return values
mixed

Meta value

getName()

Get name of local socket, or null if not connected.

public getName() : string|null
Return values
string|null

getRemoteName()

Get name of remote socket, or null if not connected.

public getRemoteName() : string|null
Return values
string|null

getTimeout()

Get timeout.

public getTimeout() : int
Return values
int

Timeout in seconds.

isConnected()

If connected to stream.

public isConnected() : bool
Return values
bool

isReadable()

If connection is readable.

public isReadable() : bool
Return values
bool

isWritable()

If connection is writable.

public isWritable() : bool
Return values
bool

ping()

Send ping.

public ping([string $message = '' ]) : Ping
Parameters
$message : string = ''

Optional text as string.

Return values
Ping

instance

pong()

Send unsolicited pong.

public pong([string $message = '' ]) : Pong
Parameters
$message : string = ''

Optional text as string.

Return values
Pong

instance

setFrameSize()

Set frame size.

public setFrameSize(int $frameSize) : self
Parameters
$frameSize : int

Frame size in bytes.

Return values
self

.

setHandshakeRequest()

public setHandshakeRequest(Request $request) : self
Parameters
$request : Request
Return values
self

setHandshakeResponse()

public setHandshakeResponse(Response $response) : self
Parameters
$response : Response
Return values
self

setLogger()

Set logger.

public setLogger(LoggerInterface $logger) : void
Parameters
$logger : LoggerInterface

Logger implementation

setMeta()

Set meta value on connection.

public setMeta(string $key, mixed $value) : void
Parameters
$key : string

Meta key

$value : mixed

Meta value

setTimeout()

Set time out on connection.

public setTimeout(int $seconds) : self
Parameters
$seconds : int

Timeout part in seconds

Return values
self

.

text()

Send text message.

public text(string $message) : Text
Parameters
$message : string

Content as string.

Return values
Text

instance

tick()

Tick operation on connection.

public tick() : void

stringable()

protected stringable(string $format, mixed ...$values) : string
Parameters
$format : string
$values : mixed
Return values
string

throwException()

protected throwException(Throwable $e) : never
Parameters
$e : Throwable
Return values
never

        
On this page

Search results