コード例 #1
0
 /**
  * @param Connexion $connexion
  * @return Buzzer
  */
 public function addNewBuzzer(Connexion $connexion)
 {
     $buzzer = new Buzzer($connexion);
     Serveur::getInstance()->getIndex()->addConnected($buzzer);
     $this[$buzzer->getId()] = $buzzer;
     return $buzzer;
 }
コード例 #2
0
ファイル: Stop.php プロジェクト: eleparquier/buzzer_server
 /**
  * @return void
  */
 function action()
 {
     parent::action();
     if ($this->ok) {
         Serveur::getInstance()->stopInstance();
     }
 }
コード例 #3
0
 /**
  * @param Connexion $connexion
  * @return Salon
  */
 public function addNewSalon(Connexion $connexion)
 {
     $salon = new Salon($connexion);
     Serveur::getInstance()->getIndex()->addConnected($salon);
     $this[$salon->getId()] = $salon;
     return $salon;
 }
コード例 #4
0
ファイル: Objects.php プロジェクト: eleparquier/buzzer_server
 function action()
 {
     parent::action();
     if ($this->ok) {
         $this->sendFreeText(Serveur::getInstance());
     }
 }
コード例 #5
0
 /**
  * @return void
  */
 function action()
 {
     /** @var Salon $salon */
     /** @var Buzzer $buzzer */
     $salon = Serveur::getInstance()->getSalons()->addNewSalon($this->getConnexion());
     $salon->setNom($this->nomSalon);
     $this->response['idSalon'] = $salon->getId();
     $this->response['nomSalon'] = $salon->getNomApparent();
     $this->sendResponse();
 }
コード例 #6
0
 /**
  * @return void
  */
 function action()
 {
     /** @var Salon $salon */
     /** @var Buzzer $buzzer */
     $this->response['idSalons'] = array();
     foreach (Serveur::getInstance()->getSalons() as $salon) {
         $this->response['idSalons'][$salon->getId()] = $salon->getNomApparent();
     }
     $this->sendResponse();
 }
コード例 #7
0
ファイル: Buzz.php プロジェクト: eleparquier/buzzer_server
 /**
  * @throws \Exception
  */
 function action()
 {
     /** @var Salon $salon */
     /** @var Buzzer $buzzer */
     if (Serveur::getInstance()->buzzerExists($this->idBuzzer)) {
         $buzzer = Serveur::getInstance()->getBuzzers()[$this->idBuzzer];
         $buzzer->buzz($this->time);
     } else {
         throw new \Exception("Buzzer " . $this->idBuzzer . " introuvable");
     }
 }
コード例 #8
0
 /**
  * @return void
  */
 function action()
 {
     if (!isset($this->password)) {
         Serveur::getInstance()->log("Action d'admin tentée, pas de mot de passe");
         $this->ok = false;
     }
     if ($this->password != Conf::getPassword() && $this->type != 'Reload') {
         Serveur::getInstance()->log("Action d'admin tentée, mauvais mot de passe");
         $this->ok = false;
     }
 }
コード例 #9
0
 /**
  * @throws \Exception
  */
 function action()
 {
     /** @var Salon $salon */
     /** @var Buzzer $buzzer */
     if (Serveur::getInstance()->salonExists($this->idSalon)) {
         $salon = Serveur::getInstance()->getSalons()[$this->idSalon];
         $salon->changerNom($this->nom);
     } else {
         throw new \Exception("Salon " . $this->idSalon . " introuvable");
     }
 }
コード例 #10
0
 /**
  * @return void
  */
 function action()
 {
     /** @var Salon $salon */
     /** @var Buzzer $buzzer */
     $buzzer = Serveur::getInstance()->getBuzzers()->addNewBuzzer($this->getConnexion());
     if ($this->pseudo) {
         $buzzer->setPseudo($this->pseudo);
     }
     $this->response['idBuzzer'] = $buzzer->getId();
     $this->response['pseudo'] = $buzzer->getPseudoApparent();
     $this->sendResponse();
 }
コード例 #11
0
 /**
  * @throws \Exception
  */
 function action()
 {
     /** @var Salon $salon */
     /** @var Buzzer $buzzer */
     if (Serveur::getInstance()->buzzerExists($this->idBuzzer) && Serveur::getInstance()->salonExists($this->idSalon)) {
         $buzzer = Serveur::getInstance()->getBuzzers()[$this->idBuzzer];
         $salon = Serveur::getInstance()->getSalons()[$this->idSalon];
         $salon->inscriptionBuzzer($buzzer);
     } else {
         throw new \Exception("Buzzer " . $this->idBuzzer . " ou salon " . $this->idSalon . " introuvables");
     }
 }
コード例 #12
0
 /**
  * Renvoie un objet du type précisé dans le champ msgType de $source
  * @param \StdClass $source
  * @param Connexion $connexion
  * @return Action
  */
 public static function make(\StdClass $source, Connexion $connexion)
 {
     $class = __NAMESPACE__ . '\\' . ucfirst($source->type);
     if (in_array(ucfirst($source->type), Serveur::getInstance()->getActions())) {
         $ret = new $class($source);
     } else {
         $ret = new Unknown($source);
     }
     /** @var Action $ret */
     $ret->setConnexion($connexion);
     $ret->setResponse(array('idConnection' => $connexion->getRessourceId(), 'msgType' => $source->type, 'error' => 0, 'errorMsg' => ''));
     return $ret;
 }
コード例 #13
0
 /**
  * @return void
  */
 function action()
 {
     /** @var Salon $salon */
     /** @var Buzzer $buzzer */
     if (Serveur::getInstance()->salonExists($this->idSalon)) {
         $salon = Serveur::getInstance()->getSalons()[$this->idSalon];
         $salon->setConnexion($this->getConnexion());
         $this->response['idSalon'] = $salon->getId();
     } else {
         $this->response['error'] = 1;
         $this->response['errorMsg'] = "Salon introuvable, un salon va être recréé.";
     }
     $this->sendResponse();
 }
コード例 #14
0
 /**
  * @throws \Exception
  */
 function action()
 {
     /** @var Salon $salon */
     /** @var Buzzer $buzzer */
     if (Serveur::getInstance()->buzzerExists($this->idBuzzer) && Serveur::getInstance()->salonExists($this->idSalon)) {
         $buzzer = Serveur::getInstance()->getBuzzers()[$this->idBuzzer];
         $salon = Serveur::getInstance()->getSalons()[$this->idSalon];
         foreach ($salon->getBuzzers() as $buz) {
             if ($buz->getId() != $buzzer->getId()) {
                 $buzzer->send(json_encode(array('idConnection' => $buzzer->getConnectionId(), 'msgType' => 'inscriptToSalon', 'error' => 0, 'errorMsg' => '', 'idSalon' => $salon->getId(), 'idBuzzer' => $buz->getId(), 'pseudo' => $buz->getPseudoApparent())));
             }
         }
     } else {
         throw new \Exception("Buzzer " . $this->idBuzzer . " ou salon " . $this->idSalon . " introuvables");
     }
 }
コード例 #15
0
 /**
  * @return void
  */
 function action()
 {
     /** @var Salon $salon */
     /** @var Buzzer $buzzer */
     if (Serveur::getInstance()->buzzerExists($this->idBuzzer)) {
         $buzzer = Serveur::getInstance()->getBuzzers()[$this->idBuzzer];
         $buzzer->setConnexion($this->getConnexion());
     } else {
         $buzzer = Serveur::getInstance()->getBuzzers()->addNewBuzzer($this->getConnexion());
     }
     $this->response['idBuzzer'] = $buzzer->getId();
     $this->response['pseudo'] = $buzzer->getPseudoApparent();
     $this->response['idSalon'] = '';
     $this->response['partieEnCours'] = false;
     $this->response['partieEnPause'] = true;
     if (!is_null($buzzer->getSalon())) {
         $this->response['idSalon'] = $buzzer->getSalon()->getId();
         $this->response['partieEnCours'] = $buzzer->getSalon()->partieEnCours();
         $this->response['partieEnPause'] = $buzzer->getSalon()->partieEnPause();
     }
     $this->sendResponse();
 }
コード例 #16
0
ファイル: Unknown.php プロジェクト: eleparquier/buzzer_server
 /**
  * @return void
  */
 function action()
 {
     Serveur::getInstance()->log('Action inconnue');
 }
コード例 #17
0
ファイル: Reload.php プロジェクト: eleparquier/buzzer_server
 /**
  * @return void
  */
 function action()
 {
     parent::action();
     Serveur::getInstance()->initConf();
 }
コード例 #18
0
ファイル: Stats.php プロジェクト: eleparquier/buzzer_server
 /**
  * @return void
  */
 function action()
 {
     $this->sendFreeText(json_encode(array('type' => 'stats', 'nbSalons' => Serveur::getInstance()->getSalons()->count(), 'nbBuzzers' => Serveur::getInstance()->getBuzzers()->count())));
 }