Log

Log::debug()
- Use this to log debug messages.

Log::error()
- Use this to log error messages.

Promise

Promise::then($success, [$fail])
- Chainable. Use this to register success and fail handlers for the promise. The success handler will be called when the Promise is resolved and the fail handler will be called when the Promise is rejected. This method can be called more than once if you want to chain multiple handlers.

Promise::catch($fail)
- Chainable. Use this to register a fail handler for the promise. The fail handler will be called when the Promise is rejected. This method can be called more than once if you want to chain multiple fail handlers.

Promise::finally($finally)
- Chainable. Use this to register a finally handler for the promise. The finally handler will be called when the Promise is either resolved or rejected. This method can be called more than once if you want to chain multiple finally handlers.

Promise::resolve($data)
- Call this when you need to resolve a Promise. The success handlers will receive the
$data
as their only argument.

Promise::reject(Exception $exception)
- Call this when you need to reject a Promise. The fail handlers will receive the
$exception
as their only argument.

DataStream

DataStream::getChunk($chunkSize)
- Called when the server is requesting a chunk of data to send. You are expected to return string no longer than $chunkSize. Note that it is not guaranteed that all of the requested data will be sent, so do not advance your data pointers yet. Wait for the call to
advanceBy()
for this.

DataStream::advanceBy($bytes)
- Called after data has been sent and
$bytes
is the number of bytes that have been sent. You should advance your data pointers by
$bytes
ahead.

DataStream::eof()
- Called when the server wants to check whether there is more data in this stream. Return FALSE if you still have data to send from this stream or TRUE otherwise.

Connection

Connection::id
- The unique ID for this connection.

Connection::ip
- The IP address of the client represented by the Connection object.

Connection::send(DataStream | String $data)
- Sends
$data
to the client represented by the Connection object. Returns a Promise.

Connection::isSecure()
- Returns TRUE if the connection is secure (SSL is enable) and FALSE otherwise.

Connection::close()
- Closes the connection.

Wrapper

Wrapper::config
- The config array as you have defined it in the config file.

Wrapper::server
- A reference to the server object..in case you need it..you would probably not need it though.

Wrapper::log
- A reference to the Log object. Use this to log messages.

Wrapper::init()
- Called when the wrapper gets loaded from the server. In most cases you can use this method instead of a constructor.

Wrapper::onConnect(Connection $con)
- Called when a new client is connected and SSL (if configured) is negotiated.

Wrapper::onDisconnect(Connection $con)
- Called after a client has disconnected from the server.

Wrapper::onData(Connection $con, $data)
- Called when new data is present from the client described using the connection $con. The $data variable is a string holding the new data. Please keep in mind that if you expect X bytes of data, you may get it in several chunks. So be sure to check buffer the data until you receive the expected amount.

Wrapper::onStop()
- Called when the server is being stopped. Think of this as a destructor.

WebSockConnection

WebSockConnection::id
- The unique ID for this connection.

WebSockConnection::ip
- The IP address of the client represented by the WebSockConnection object.

WebSockConnection::endpoint
- The endpoint for the connection. This is specified by the client when connecting. You can use this to separate chat clients in rooms for example.

WebSockConnection::send(String $data[, $send_as_binary = false])
- Sends
$data
to the client represented by the WebSockConnection object. Returns a Promise.

WebSockConnection::isSecure()
- Returns TRUE if the connection is secure (SSL is enable) and FALSE otherwise.

WebSockConnection::close()
- Closes the connection.

WebSocketComponent

WebSocketComponent::$PROTOCOL
- A string field used when the server registers your component. Only clients that request this protocol will be connected to this component instance.

WebSocketComponent::$server
- A reference to the server object..in case you need it..you would probably not need it though.

WebSocketComponent::onLoad($ip, $port, $host)
- Called when the component gets loaded from the server. In most cases you can use this method instead of a constructor.

WebSocketComponent::onConnect(WebSockConnection $con)
- Called when a new client is connected and SSL (if configured) is negotiated.

WebSocketComponent::onDisconnect(WebSockConnection $con)
- Called after a client has disconnected from the server.

WebSocketComponent::onMessage(WebSockConnection $con, $data, $dataType)
- Called when new data is present from the client described using the connection $con. The $dataType can be either 'text' or 'binary' which tells you whether the received data should be treated as text or binary.

HttpRequest

HttpRequest::getCookie($name)
- Returns the value of the cookie specified by $name or NULL if there is no such cookie in the request.

HttpRequest::getHeader($name)
- Returns the value of the header specified by $name or NULL if there is no such header in the request.

HttpRequest::getHttpVersion()
- Returns the HTTP version used in the request.

HttpRequest::getHeaders()
- Returns an associative array with all headers from the request.

HttpRequest::getMethod()
- Returns the HTTP method used in the request. Example "GET".

HttpRequest::getPath()
- Returns the path used in the request.

HttpRequest::getQuery()
- Returns an associative array with the query parameters used in the request.

HttpRequest::getPayload()
- Returns the payload data used in the request.

HttpResponse

HttpResponse::setHeader($name, $value)
- Sets a header. This will not work if you call it after a call to HttpResponse::write().

HttpResponse::setStatusCode($code[, $message = NULL])
- Sets the status code for the response. Example 301 Moved Permanently.

HttpResponse::write($data)
- Send the $data as a reponse to the client. Returns a promise. For $data can be only string, but soon (file)streams will be supported also.

HttpComponent

HttpComponent::$PATH
- A string field used when the server registers your component. Only clients that request this path will be forwarded to this component instance. This means that you need to code a separate component for each path that you want to support. When multiple components are registered, the one with the longest match will be selected to handle a request.

HttpComponent::$server
- A reference to the server object..in case you need it..you would probably not need it though.

HttpComponent::onLoad($ip, $port, $host)
- Called when the component gets loaded from the server. In most cases you can use this method instead of a constructor.

HttpComponent::onRequest(Connection $con, HttpRequest $request, HttpResponse $response)
- Called when a new request hits the server. The $con parameter is a reference to the connection which made the request. The $request is an object describing the request. The $response is an object that you will use to send back a response.