/**
* Handler triggered when a new connection is received from SocketListener.
*
* @param SocketListenerInterface $server
* @param SocketInterface $socket
*/
public function handleConnect($server, $socket)
{
$socket->conn = new NetworkConnection($socket);
try {
$this->component->handleConnect($socket->conn);
$socket->on('data', [$this, 'handleData']);
$socket->on('error', [$this, 'handleError']);
$socket->on('close', [$this, 'handleDisconnect']);
} catch (Error $ex) {
$this->close($socket);
} catch (Exception $ex) {
$this->close($socket);
}
}