/** * @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; }
/** * @return void */ function action() { parent::action(); if ($this->ok) { Serveur::getInstance()->stopInstance(); } }
/** * @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; }
function action() { parent::action(); if ($this->ok) { $this->sendFreeText(Serveur::getInstance()); } }
/** * @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(); }
/** * @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(); }
/** * @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"); } }
/** * @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; } }
/** * @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"); } }
/** * @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(); }
/** * @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"); } }
/** * 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; }
/** * @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(); }
/** * @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"); } }
/** * @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(); }
/** * @return void */ function action() { Serveur::getInstance()->log('Action inconnue'); }
/** * @return void */ function action() { parent::action(); Serveur::getInstance()->initConf(); }
/** * @return void */ function action() { $this->sendFreeText(json_encode(array('type' => 'stats', 'nbSalons' => Serveur::getInstance()->getSalons()->count(), 'nbBuzzers' => Serveur::getInstance()->getBuzzers()->count()))); }