Property | Type | Description | |
---|---|---|---|
$clients | The connected clients. | ||
$config | Configuration information used by the server. | ||
$events | Dictionary of events and the callbacks attached to them. | ||
$logger | Monolog logger interface | ||
$max_clients | The maximum number of clients allowed to connect. | ||
$max_read | The maximum number of bytes to read from a socket at a single time. | ||
$shutdown | True if on the next iteration, the server should shutdown. | ||
$socket | The socket used by the server. | ||
$started | if the server has started | ||
$tv_sec | Connection timeout |
Method | Description | |
---|---|---|
__construct ( array $config, |
Creates the socket and starts listening to it. | |
__toString ( ) : string | Generate a string representation of this server. | |
close ( ) | Closes the socket on shutdown | |
disconnect ( |
Disconnect a client | |
fire ( string $event, |
Raise a given event with the supplied data. | |
forget ( string $event, mixed $callback ) : true | Deletes a function from the call list for a certain action | |
fwrite ( resource $fh, string $string ) | Write a string to a resource | |
listen ( string $event, mixed $callback ) : true | Adds a function to be called whenever a certain action happens | |
log ( ) | Send log message to logger | |
onConnect ( mixed $callback ) : mixed | Helper function to make using connect event easier | |
onDisconnect ( mixed $callback ) : mixed | Helper function to make using disconnect event easier | |
onReceive ( mixed $callback ) : mixed | Helper function to make using receive event easier | |
run ( ) | Runs the server code until the server is shut down. | |
send ( |
Writes data to the socket, including the length of the data, and ends it with a CRLF unless specified. | |
shutdown ( ) | Schedule a shutdown. Will finish processing the current run. | |
start ( ) | Starts the server |
public __construct ( array $config, |
||
$config | array | Array of configuration options |
$logger | Output logger |
public __toString ( ) : string | ||
return | string | String identifier for this server instance. |
public disconnect ( |
||
$client | The client to disconnect | |
$message | string | Data to write to the socket. |
return | mixed |
public onDisconnect ( mixed $callback ) : mixed | ||
$callback | mixed | Any callback callable by call_user_func_array. |
return | mixed |
public send ( |
||
$client | Connected client to write to | |
$message | string | Data to write to the socket. |
$end | string | Data to end the line with. Specify false if you don't want a line end sent. |
return | mixed | Returns the number of bytes successfully written to the socket or FALSE on failure. The error code can be retrieved with socket_last_error(). This code may be passed to socket_strerror() to get a textual explanation of the error. |
public shutdown ( ) |
protected $events |
protected $max_clients |
protected $max_read |
protected $shutdown |