HttpServer

An HTTP and WebSockets server.

You receive HTTP requests by providing a @see \io\vertx\jphp\core\http\HttpServer::requestHandler. As requests arrive on the server the handler will be called with the requests.

You receive WebSockets by providing a @see \io\vertx\jphp\core\http\HttpServer::websocketHandler. As WebSocket connections arrive on the server, the WebSocket is passed to the handler.

package

Default

Methods

__construct

__construct() 

The actual port the server is listening on. This is useful if you bound the server specifying 0 as port number signifying an ephemeral port

actualPort() : integer

Response

integer

the actual port the server is listening on.

Like @see \io\vertx\jphp\core\http\HttpServer::close but supplying a handler that will be called when the server is actually closed (or has failed).

close( $arg0) : void

Arguments

$arg0

callable

Set a connection handler for the server.

connectionHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

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

Set an exception handler called for socket errors happening before the HTTP connection is established, e.g during the TLS handshake.

exceptionHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

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

Whether the metrics are enabled for this measured object

isMetricsEnabled() : boolean

Response

boolean

{@code true} if metrics are enabled

Like @see \io\vertx\jphp\core\http\HttpServer::listen but supplying a handler that will be called when the server is actually listening (or has failed).

listen( $arg0,  $arg1 = null,  $arg2 = null) : $this

param $listenHandler [callable] the listen handler listen($listenHandler)

Tell the server to start listening on the given address supplying a handler that will be called when the server is actually listening (or has failed).

param $address [SocketAddress] the address to listen on param $listenHandler [callable] the listen handler listen($address, $listenHandler)

Like @see \io\vertx\jphp\core\http\HttpServer::listen but supplying a handler that will be called when the server is actually listening (or has failed).

param $port [integer] the port to listen on param $listenHandler [callable] the listen handler listen($port, $listenHandler)

Like @see \io\vertx\jphp\core\http\HttpServer::listen but supplying a handler that will be called when the server is actually listening (or has failed).

param $port [integer] the port to listen on param $host [string] the host to listen on param $listenHandler [callable] the listen handler listen($port, $host, $listenHandler)

Arguments

$arg0

callable | integer | SocketAddress

$arg1

callable | string

$arg2

callable

Response

$this

Set the request handler for the server to <code>requestHandler</code>. As HTTP requests are received by the server, instances of @see \io\vertx\jphp\core\http\HttpServerRequest will be created and passed to this handler.

requestHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

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

Return the request stream for the server. As HTTP requests are received by the server, instances of @see \io\vertx\jphp\core\http\HttpServerRequest will be created and passed to the stream .

requestStream() : \io\vertx\jphp\core\http\ReadStream<HttpServerRequest>

Response

\io\vertx\jphp\core\http\ReadStream

the request stream

Set the websocket handler for the server to <code>wsHandler</code>. If a websocket connect handshake is successful a new @see \io\vertx\jphp\core\http\ServerWebSocket instance will be created and passed to the handler.

websocketHandler( $arg0) : $this

Arguments

$arg0

callable

Response

$this

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

Return the websocket stream for the server. If a websocket connect handshake is successful a new @see \io\vertx\jphp\core\http\ServerWebSocket instance will be created and passed to the stream .

websocketStream() : \io\vertx\jphp\core\http\ReadStream<ServerWebSocket>

Response

\io\vertx\jphp\core\http\ReadStream

the websocket stream