Skip to content

Commit

Permalink
Lobby function changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashikkalis committed Dec 20, 2024
1 parent 23a44da commit 5f2bda1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion blokus.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function routeRequest($input) {
$router->add('GET', 'users/session', 'checkSession'); // GET /users/session -> checkSession function

//lobby functions
$router->add('GET', 'lobbys', 'getLobbys');
$router->add('GET', 'lobbys', 'getLobbies');


// Handle the request
Expand Down
13 changes: 5 additions & 8 deletions lib/lobbys.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@

header('Content-Type: application/json');

function getLobbys() {
function getLobbies() {
$pdo = getDatabaseConnection();
try {
// Fetch all active lobbies where the status is 'waiting'
$sql = 'SELECT * FROM game_lobbies';
$sql = "SELECT * FROM game_lobbies";
$stmt = $pdo->query($sql);
$stmt->fetchAll(); // Return the list of active lobbies
$lobbys = $stmt->fetch(PDO::FETCH_ASSOC);
echo json_encode($lobbys, JSON_PRETTY_PRINT);
$lobbies = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($lobbies, JSON_PRETTY_PRINT);
} catch (PDOException $e) {
echo json_encode (['error' => 'Error in getLobbys(): ' . $e->getMessage()]);
echo json_encode(['error' => 'Error in getLobbies(): ' . $e->getMessage()]);
}
}



?>

0 comments on commit 5f2bda1

Please sign in to comment.