Guest User

Untitled

a guest
Sep 22nd, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.26 KB | None | 0 0
  1. class ProductGameServer {
  2.     /**
  3.      * Démarrer un serveur de jeu
  4.      *
  5.      * @param int $gameserverId
  6.      * @return mixed
  7.      */
  8.     public function GameServer_Game_Start($gameserverId) {
  9.         try {
  10.         //Initialisation d'une installation
  11.             $gameinstall = new GameInstall();
  12.         $gameinstallId = $gameinstall->getGameInstallIdByServerOnly($gameserverId);
  13.  
  14.             //Récupération des informations DB d'un serveur de jeu
  15.             $gameserverInfos = $this->getInfoGameServer($gameserverId);
  16.            
  17.         //Vérification si le jeu est défini en tant qu'architecture non standard
  18.             if(class_exists($gameserverInfos->soap_game)) {
  19.  
  20.         //Initialisation de la classe dédiée au jeu
  21.                 $gameClass = new $gameserverInfos->soap_game;
  22.                
  23.         //Vérification de l'existence d'une fonction de démarrage spécifique pour ce jeu                                    
  24.                 if(method_exists($gameClass,'Service_' . $gameserverInfos->soap_game . '_Start')) {
  25.             //Utilisation de la fonction spécifique pour le démarrage
  26.                     $useOwnClass = true;
  27.                 }
  28.             }
  29.  
  30.         //Lancement d'un démarrage spécifique pour le jeu
  31.             if($useOwnClass === true) {
  32.                 call_user_func(array($gameClass, 'Service_' . $gameserverInfos->soap_game . '_Start'), array($gameserverId, 'GameServer',&$zidReturn));
  33.                 return $zidReturn;
  34.             } else {
  35.         //Initialisation d'un service client
  36.                 $customerproduct = new CustomerProduct();
  37.                 $customerproductInfos = $customerproduct->getCustomerProduct($gameserverInfos->customerproduct_id);
  38.        
  39.         //Initialisation d'un serveur (machine)
  40.                 $server = new Server();
  41.                 $serverInfos = $server->getInfoServer($gameserverInfos->id_server);
  42.  
  43.         //Initialisation d'une opération du robot de traitement Ziggy
  44.                 $ziggyoperation = new ZiggyOperation();
  45.  
  46.         //Construction de l'opération à envoyer
  47.                 $infos = array(
  48.                         'customer_id' => $customer->id_customer,
  49.                         'function_ziggyoperation' => 'GameServer_'.$gameserverInfos->soap_game.'_Start',
  50.                         'params_ziggyoperation' => array(
  51.                             $serverInfos->address_ip,         //Adresse IP de la machine
  52.                             $customerproductInfos->customer_id,   //Identification client sur le NAS
  53.                             $gameserverInfos->name_serveronly,    //Nom du serveur de jeu
  54.                             $gameserverInfos->port_serveronly),   //Port du serveur de jeu
  55.                         'actionok_ziggyoperation' => 'ProductGameServer:editStatusGameServer:2,'.$gameserverId         //Edition du statut du serveur
  56.                     );
  57.                
  58.                 }
  59.        
  60.         //Envoi de l'opération et récupération de l'identifiant de suivi
  61.                 $ziggyId = $ziggyoperation->createZiggyOperation($infos,false);
  62.                 if($ziggyId) {
  63.                     return $ziggyId;
  64.                 } else {
  65.                     return false;
  66.                 }
  67.             }
  68.         } catch (Exception $e) {
  69.             throw new Exception($e->getMessage());
  70.         }
  71.     }
  72. }
Add Comment
Please, Sign In to add comment