/**
* __construct
* @param Application $appInstance [@todo description]
* @param string $id [@todo description]
* @param array $server [@todo description]
* @return void
*/
public function __construct($appInstance, $id, $server)
{
$this->onWrite = new StackCallbacks();
$this->id = $id;
$this->appInstance = $appInstance;
$this->server = $server;
if (isset($this->server['HTTP_COOKIE'])) {
Generic::parseStr(strtr($this->server['HTTP_COOKIE'], Generic::$hvaltr), $this->cookie);
}
if (isset($this->server['QUERY_STRING'])) {
Generic::parseStr($this->server['QUERY_STRING'], $this->get);
}
$this->addr = $server['REMOTE_ADDR'];
$this->finishTimer = setTimeout(function ($timer) {
$this->finish();
}, $this->timeout * 1000000.0);
$this->appInstance->subscribe('c2s:' . $this->id, [$this, 'c2s']);
$this->appInstance->subscribe('poll:' . $this->id, [$this, 'poll'], function ($redis) {
$this->appInstance->publish('state:' . $this->id, 'started', function ($redis) {
// @TODO: remove this callback
});
});
}