SockJSSocket

You interact with SockJS clients through instances of SockJS socket.

The API is very similar to @see \io\vertx\jphp\core\http\WebSocket. It implements both and so it can be used with

see

to pump data with flow control.

package

Default

Methods

__construct

__construct() 

Close it

close( $arg0 = null,  $arg1 = null) : void

close()

Close it giving a status code and reason. Only Applicable to RawWebSocket will downgrade to plain close for other transports.

param $statusCode [integer] param $reason [string] close($statusCode, $reason)

Arguments

$arg0

integer

$arg1

string

drainHandler

drainHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

Same as @see \io\vertx\jphp\ext\web\handler\sockjs\SockJSSocket::end but with an <code>handler</code> called when the operation completes

end( $arg0,  $arg1 = null) : void

param $handler [callable] end($handler)

Same as but with an handler called when the operation completes

param $data [Buffer] param $handler [callable] end($data, $handler)

Arguments

$arg0

Buffer | callable

$arg1

callable

endHandler

endHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

exceptionHandler

exceptionHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

Fetch the specified <code>amount</code> of elements. If the <code>ReadStream</code> has been paused, reading will recommence with the specified <code>amount</code> of items, otherwise the specified <code>amount</code> will be added to the current stream demand.

fetch( $arg0) : $this

Arguments

$arg0

integer

Response

$this

a reference to this, so the API can be used fluently

handler

handler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

Return the headers corresponding to the last request for this socket or the websocket handshake Any cookie headers will be removed for security reasons

headers() : \io\vertx\jphp\core\MultiMap

Return the local address for this socket

localAddress() : \io\vertx\jphp\core\net\SocketAddress

pause

pause() : $this

Response

$this

Pause this stream and return a to transfer the elements of this stream to a destination .

pipe() : \io\vertx\jphp\ext\web\handler\sockjs\Pipe<Buffer>

The stream will be resumed when the pipe will be wired to a WriteStream.

Response

\io\vertx\jphp\ext\web\handler\sockjs\Pipe

a pipe

Pipe this <code>ReadStream</code> to the <code>WriteStream</code>.

pipeTo( $arg0,  $arg1) : void

Elements emitted by this stream will be written to the write stream until this stream ends or fails.

Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

Arguments

$arg0

WriteStream

$arg1

callable

Return the remote address for this socket

remoteAddress() : \io\vertx\jphp\core\net\SocketAddress

resume

resume() : $this

Response

$this

setWriteQueueMaxSize

setWriteQueueMaxSize( $arg0) : $this

Arguments

$arg0

integer

Response

$this

Return the URI corresponding to the last request for this socket or the websocket handshake

uri() : string

Response

string

webSession

webSession() : \io\vertx\jphp\ext\web\Session

Response

\io\vertx\jphp\ext\web\Session

the Vert.x-Web session corresponding to this socket

webUser

webUser() : \io\vertx\jphp\ext\auth\User

Response

\io\vertx\jphp\ext\auth\User

the Vert.x-Web user corresponding to this socket

Write a {@link java.lang.String} to the socket, encoded in UTF-8.

write( $arg0,  $arg1 = null) : void

param $data [string] the string to write write($data)

param $data [string] param $handler [callable] write($data, $handler)

param $data [Buffer] param $handler [callable] write($data, $handler)

Arguments

$arg0

Buffer | string

$arg1

callable

When a <code>SockJSSocket</code> is created it automatically registers an event handler with the event bus, the ID of that handler is given by <code>writeHandlerID</code>.

writeHandlerID() : string

Given this ID, a different event loop can send a buffer to that event handler using the event bus and that buffer will be received by this instance in its own event loop and written to the underlying socket. This allows you to write data to other sockets which are owned by different event loops.

Response

string

This will return <code>true</code> if there are more bytes in the write queue than the value set using @see \io\vertx\jphp\ext\web\handler\sockjs\SockJSSocket::setWriteQueueMaxSize

writeQueueFull() : boolean

Response

boolean

true if write queue is full