function onStart($serv) { parent::onStart($serv); if (empty($this->apps_path)) { if (!empty($this->config['apps']['apps_path'])) { $this->apps_path = $this->config['apps']['apps_path']; } else { throw new AppServerException("AppServer require apps_path"); } } $php = Swoole::getInstance(); $php->addHook(Swoole::HOOK_CLEAN, function () { $php = Swoole::getInstance(); //模板初始化 if (!empty($php->tpl)) { $php->tpl->clear_all_assign(); } //还原session if (!empty($php->session)) { $php->session->open = false; $php->session->readonly = false; } }); }
/** * 清理连接缓存区 * @param $fd */ function cleanBuffer($fd) { unset($this->frame_list[$fd], $this->connections[$fd]); parent::cleanBuffer($fd); }
function onClose($serv, $client_id, $from_id) { $this->log("close client_id = {$client_id}"); unset($this->ws_list[$client_id], $this->connections[$client_id], $this->requests[$client_id]); parent::onClose($serv, $client_id, $from_id); }