protected function __construct()
 {
     Dispatcher::register(ServerEvent::getClass(), $this, ServerEvent::ON_PLAYER_CHAT);
     $command = new Command('help', 0);
     $command->addLoginAsFirstParameter = true;
     $command->log = false;
     $command->help = 'Display all visible commands to a player it takes no parameter';
     $command->callback = array($this, 'help');
     $this->register($command);
     $command = new Command('man', 1);
     $command->addLoginAsFirstParameter = true;
     $command->help = 'Display help for every commands you give as parameter' . "\n" . 'exemple of usage: /man man';
     $command->isPublic = true;
     $command->log = false;
     $command->callback = array($this, 'man');
     $this->register($command);
     $command = new Command('man', 2);
     $command->addLoginAsFirstParameter = true;
     $command->help = 'Display help for the command with the corresponding parameters' . "\n" . 'exemple of usage: /man man 2';
     $command->isPublic = true;
     $command->log = false;
     $command->callback = array($this, 'man');
     $this->register($command);
     $config = \ManiaLive\DedicatedApi\Config::getInstance();
     $this->connection = Connection::factory($config->host, $config->port, $config->timeout, $config->user, $config->password);
 }
 public function tryConnect()
 {
     Console::out(Console::b_green . "Dedicated server connection setup:\n");
     Console::out(Console::white . "Please enter dedicated server ip (127.0.0.1): ");
     $this->ip = $this->getInput("127.0.0.1");
     Console::out(Console::white . "Please enter dedicated xml-rpc port (5000): ");
     $this->port = (int) $this->getInput(5000);
     Console::out(Console::white . "Please enter dedicated user (SuperAdmin): ");
     $this->user = $this->getInput("SuperAdmin");
     Console::out(Console::white . "Please enter dedicated password (SuperAdmin): ");
     $this->pass = $this->getInput("SuperAdmin");
     $connection = null;
     try {
         Console::out("Trying to connect...", "Connect", Console::b_green);
         $this->connection = \Maniaplanet\DedicatedServer\Connection::factory($this->ip, $this->port, 5, $this->user, $this->pass);
         $this->connection->isRelayServer();
         Console::success();
         Console::outTm("Connected to server: " . $this->connection->getServerName() . "\n");
     } catch (\Exception $ex) {
         Console::fail();
         Console::out_error($ex->getMessage());
         Console::out("Try again (y)?");
         if ($this->getInput("y") == "y") {
             $this->tryConnect();
         } else {
             Console::out(Console::white . "Setup aborted. No config written.");
             exit(0);
         }
     }
     return;
 }
 protected function __construct()
 {
     $this->identifier = 'ManiaLive ' . \ManiaLive\Application\VERSION;
     $config = Config::getInstance();
     $this->connection = Connection::factory($config->host, $config->port, $config->timeout, $config->user, $config->password);
     Dispatcher::register(Event::getClass(), $this, Event::ON_ECHO);
 }
 function start()
 {
     $configFile = $this->request->getPostStrict('configFile');
     $spectate = $this->request->getPostStrict('spectate');
     list($options, $account, $system, $authLevel, $isLan) = $this->fetchAndAssertConfig(_('starting it'));
     $spectate = \DedicatedManager\Services\Spectate::fromArray($spectate);
     switch ($spectate->method) {
         case 'managed':
             try {
                 list($rpcHost, $rpcPort, $rpcPass) = explode(':', $spectate->managed, 3);
                 $connection = \Maniaplanet\DedicatedServer\Connection::factory($rpcHost, $rpcPort, 5, 'SuperAdmin', $rpcPass);
                 $info = $connection->getSystemInfo();
                 $gameServer = $info->publishedIp . ':' . $info->port;
                 $password = $connection->getServerPasswordForSpectator();
             } catch (\Exception $e) {
                 $errors[] = _('Cannot retrieve server connection');
             }
             break;
         case 'ip':
             $gameServer = $spectate->ip . ':' . $spectate->port;
             $password = $spectate->password;
             break;
         case 'login':
             $gameServer = $spectate->login;
             $password = $spectate->password;
             break;
     }
     $this->session->set('configFile', $configFile);
     $this->session->set('spectate', $spectate);
     $errors = array();
     if (strpbrk($configFile, '\\/:*?"<>|')) {
         $errors[] = _('The server config filename must not contain any of the following characters: \\ / : * ? " < > |');
     }
     if (!$errors) {
         try {
             $error = _('An error appeared while writing the server configuration file');
             $service = new \DedicatedManager\Services\ConfigFileService();
             $service->save($configFile, $options, $account, $system, $authLevel);
             $error = _('An error appeared while starting the server');
             $service = new \DedicatedManager\Services\ServerService();
             $server = new \DedicatedManager\Services\Server();
             $server->rpcHost = '127.0.0.1';
             $server->rpcPort = $service->startRelay($configFile, $gameServer, $password, $isLan);
             $server->rpcPassword = $authLevel->superAdmin;
             $service->register($server);
         } catch (\Exception $e) {
             \ManiaLib\Application\ErrorHandling::logException($e);
             $errors[] = $error;
         }
     }
     if ($errors) {
         $this->session->set('error', $errors);
         $this->request->redirectArgList('../spectate');
     }
     $this->session->set('success', _('Your relay server has been successfully started'));
     $this->goHome();
 }
Example #5
0
 final function __construct()
 {
     $this->dependencies = array();
     $this->methods = array();
     $this->id = "\\" . get_class($this);
     $this->setVersion(1);
     $config = \ManiaLive\DedicatedApi\Config::getInstance();
     $this->connection = Connection::factory($config->host, $config->port, $config->timeout, $config->user, $config->password);
     $this->pluginHandler = PluginHandler::getInstance();
     $this->storage = Storage::getInstance();
     $this->chatCommands = array();
 }
Example #6
0
 protected function __construct()
 {
     $this->modalBg = new Bgs1(340, 200);
     $this->modalBg->setSubStyle(Bgs1::BgDialogBlur);
     $this->modalBg->setAlign('center', 'center');
     $this->modalBg->setPosZ(Window::Z_MODAL);
     $this->modalBg->setScriptEvents();
     $this->nextLoop = microtime(true);
     Dispatcher::register(AppEvent::getClass(), $this, AppEvent::ALL & ~AppEvent::ON_POST_LOOP);
     Dispatcher::register(PlayerEvent::getClass(), $this, PlayerEvent::ON_PLAYER_CHANGE_SIDE);
     Dispatcher::register(ServerEvent::getClass(), $this, ServerEvent::ON_PLAYER_CONNECT | ServerEvent::ON_PLAYER_DISCONNECT);
     $config = \ManiaLive\DedicatedApi\Config::getInstance();
     $this->connection = Connection::factory($config->host, $config->port, $config->timeout, $config->user, $config->password);
 }
 protected function init()
 {
     \ManiaLive\Utilities\Console::println('Running ManiaLive ' . VERSION . '...');
     new \ManiaLive\Features\Tick\Ticker();
     $config = \ManiaLive\DedicatedApi\Config::getInstance();
     $this->connection = Connection::factory($config->host, $config->port, $config->timeout, $config->user, $config->password);
     $this->connection->enableCallbacks(true);
     \ManiaLive\Data\Storage::getInstance();
     \ManiaLive\Features\ChatCommand\Interpreter::getInstance();
     \ManiaLive\Features\EchoHandler::getInstance();
     \ManiaLive\Gui\GuiHandler::getInstance();
     \ManiaLive\PluginHandler\PluginHandler::getInstance();
     Dispatcher::dispatch(new Event(Event::ON_INIT));
 }
Example #8
0
 function status($host, $port)
 {
     $service = new \DedicatedManager\Services\ServerService();
     try {
         $server = $service->get($host, $port);
         $this->connection = \Maniaplanet\DedicatedServer\Connection::factory($server->rpcHost, $server->rpcPort, 5, 'SuperAdmin', $server->rpcPassword);
         $info = $this->connection->getSystemInfo();
         $this->response->running = $info->serverLogin;
     } catch (\Exception $e) {
         $this->response->running = 0;
     }
 }
Example #9
0
 function openConnection()
 {
     $this->connection = \Maniaplanet\DedicatedServer\Connection::factory($this->rpcHost, $this->rpcPort, 5, 'SuperAdmin', $this->rpcPassword);
 }
Example #10
0
 function onInit()
 {
     $config = \ManiaLive\DedicatedApi\Config::getInstance();
     $this->connection = Connection::factory($config->host, $config->port, $config->timeout, $config->user, $config->password);
     $this->serverStatus = $this->connection->getStatus();
     $players = $this->connection->getPlayerList(-1, 0);
     foreach ($players as $player) {
         try {
             $details = $this->connection->getDetailedPlayerInfo($player->login);
             foreach ($details as $key => $value) {
                 if ($value) {
                     $player->{$key} = $value;
                 }
             }
             if ($player->spectatorStatus % 10 == 0) {
                 $this->players[$player->login] = $player;
             } else {
                 $this->spectators[$player->login] = $player;
             }
         } catch (\Exception $e) {
         }
     }
     try {
         $this->maps = $this->connection->getMapList(-1, 0);
         $this->currentMap = $this->connection->getCurrentMapInfo();
         if (isset($this->maps[$this->connection->getNextMapIndex()])) {
             $this->nextMap = $this->maps[$this->connection->getNextMapIndex()];
         } else {
             $this->nextMap = null;
         }
     } catch (\Exception $e) {
         $this->maps = array();
         $this->nextMap = null;
         $this->currentMap = null;
     }
     $this->server = $this->connection->getServerOptions();
     $this->gameInfos = $this->connection->getCurrentGameInfo();
     try {
         $this->serverLogin = $this->connection->getSystemInfo()->serverLogin;
     } catch (\Exception $e) {
         $this->serverLogin = null;
     }
 }