Skip to content

Commit

Permalink
Test1 'leaveLobby' function
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashikkalis committed Dec 23, 2024
1 parent ddeae9c commit 88ef99d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions blokus.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,15 @@ public function routeRequest($input) {
}
});

$router->add('POST', 'lobbys/leave', function($input) {
if (isset($input['userId']) && isset($input['lobbyId'])) {
leaveLobby((int)$input['userId'], (int)$input['lobbyId']);
} else {
echo json_encode(['error' => 'Missing userId or lobbyId parameters']);
}
});
$router->add('POST', 'lobbys/leave', 'leaveLobby');

// $router->add('POST', 'lobbys/leave', function($input) {
// if (isset($input['userId']) && isset($input['lobbyId'])) {
// leaveLobby((int)$input['userId'], (int)$input['lobbyId']);
// } else {
// echo json_encode(['error' => 'Missing userId or lobbyId parameters']);
// }
// });

// Handle the request
$input = json_decode(file_get_contents('php://input'), true);
Expand Down
2 changes: 1 addition & 1 deletion lib/lobbys.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function joinLobby($userId, $lobbyId) {
}
}

function leaveLobby($userId, $lobbyId) {
function leaveLobby() {
$pdo = getDatabaseConnection();

$sql = "DELETE FROM game_lobbies WHERE id = '2'";
Expand Down

0 comments on commit 88ef99d

Please sign in to comment.