_config = $configuration; $this->_clients = new \SplObjectStorage; self::$_app = $this; } /** * @param $version float */ public function setVersion($version) { $this->_version = $version; } /** * @return float */ public function getVersion() { return $this->_version; } public function setupRoutes() { require_once __DIR__ . '/../../../../../../app/routes.php'; $router = LuRoute::getInstance(); $router->setup(); } public function runHttp() { $httpMethod = $_SERVER['REQUEST_METHOD']; $url = $_SERVER['REQUEST_URI']; $router = LuRoute::getInstance(); $parameters = array_merge($_GET, $_POST); $router->dispatch($httpMethod, $url, $parameters); } public function runWs() { $server = IoServer::factory( new HttpServer( new WsServer( $this ) ), $this->_config['websocket']['port'], $this->_config['websocket']['address'] ); $server->run(); } function onMessage(ConnectionInterface $from, $msg) { // TODO: Implement onMessage() method. } function onOpen(ConnectionInterface $conn) { $this->_clients->attach($conn); } function onClose(ConnectionInterface $conn) { $this->_clients->detach($conn); } function onError(ConnectionInterface $conn, \Exception $e) { $conn->close(); } }