} else { echo json_encode(array("error" => true, "data" => "Accesso no permitido")); } } else { $this->resolveService($service, $params, $conn); } } else { echo json_encode(array("error" => true, "data" => "Servicio no disponible")); } } protected function connected($conn) { //Recogemos token de sesión // Do nothing: This is just an echo server, there's no need to track the user. // However, if we did care about the users, we would probably have a cookie to // parse at this step, would be looking them up in permanent storage, etc. } protected function closed($conn) { //echo $this->clients->count(); // Do nothing: This is where cleanup would go, in case the user had any sort of // open files or other objects associated with them. This runs after the socket // has been closed, so there is no need to clean up the socket itself here. } } $ss = new ServerSocket("127.0.0.1", "30000"); try { $ss->run(); } catch (Exception $e) { $ss->stdout($e->getMessage()); }