/**
* Builds internal request handling objects.
*
* @return $this
*/
public function build()
{
if ($this->cache) {
$loader = new ClassLoader();
if ($this->apc) {
$apcLoader = new ApcClassLoader(sha1('ReactServer'), $loader);
$loader->unregister();
$apcLoader->register(true);
}
}
require_once $this->root_dir . '/AppKernel.php';
define('KERNEL_ROOT', $this->root_dir);
$kernel = new ReactKernel($this->env, $this->env === 'dev' ? true : false);
$this->loop = Factory::create();
// TODO make config for this part
if (class_exists('\\Doctrine\\DBAL\\Driver\\PingableConnection')) {
$this->loop->addPeriodicTimer(15, function () use($kernel) {
foreach ($kernel->getContainer()->get('doctrine')->getConnections() as $connection) {
if ($connection instanceof \Doctrine\DBAL\Driver\PingableConnection) {
$connection->ping();
}
}
});
}
$this->socket = new SocketServer($this->loop);
$http = new HttpServer($this->socket, $this->loop);
$http->on('request', $this->handleRequest($kernel));
return $this;
}