<?php /** * Ce fichier s'occupe du process lorsqu'un joueur souhaite rejoindre une room * Appelé par le fichier "www/include/navigation.php" */ //On vérifie si les session sont déja activées if (session_id() == null) { session_start(); } include "connexion.php"; if (isset($_GET['room_id']) && isset($_SESSION['usr_id'])) { join_room($_GET['room_id'], $_SESSION['usr_id'], $bdd); } function join_room($id_room, $user_id, $bdd) { //On vérifie si l'utilisateur n'a pas déja rejoint la room $search_playeur = $bdd->query("SELECT *\n FROM user_has_room\n WHERE statut_usr_room = 'out'\n AND id_room= " . $id_room . "\n AND id_user="******"INSERT INTO user_has_room (id_room, id_user,usr_admin, statut_usr_room) VALUES (:room_id, :user_id, 0, 'in')"); $user_has_room->execute(array('room_id' => $id_room, 'user_id' => $user_id)); } else { $bdd->exec("UPDATE user_has_room \n SET statut_usr_room = 'in'\n WHERE id_room= " . $id_room . "\n AND id_user="******"SELECT room_nb_joueur\n FROM room\n WHERE room_id = " . $id_room); $limit_joueur = $limit_joueur->fetch(); $nb_joueur = $bdd->query("SELECT COUNT(*) as nb\n FROM user_has_room\n WHERE statut_usr_room = 'in'\n AND id_room =" . $id_room); $nb_joueur = $nb_joueur->fetch();
// Client joins a room. The room could be specified in the url otherwise // a random room is made. if (isset($_GET['room_id'])) { $room_id = $_GET['room_id']; if (strlen($room_id) != 6) { $error = "Error! invalid room"; } else { ensure_room_exists($room_id, $client_id); } } else { $room_id = new_room($client_id); } // Join the room. A join room signal will be broadcast by the server on // the client's behalf, even before the signaller is built on the client. // Maybe you want to let client send join message with her signaller join_room($room_id, $client_id); $initiator_id = get_initiator($room_id); // The initiator of the room is passive, and waits for newcommers to // initiate. Hence, the room initiator is never the call-initiator! $initiator = $initiator_id == $client_id ? 'false' : 'true'; $is_first = $initiator_id == $client_id ? 'true' : 'false'; // Generate a url for this room. Users might share by email or IM to // get connected $room_file_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; $room_id_url = "?room_id={$room_id}"; $room_url = $room_file_url . $room_id_url; ?> <html> <head> <meta name="viewport"