Initial commit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
const Game = require("../../../Game/Game");
|
||||
|
||||
const isAuthenticated = require("../../../Utility/isAuthenticated");
|
||||
|
||||
module.exports = async (res, req) => {
|
||||
res.onAborted(() => res.isAborted = true);
|
||||
|
||||
const playerID = req.getQuery("playerId");
|
||||
|
||||
const hasPermission = await isAuthenticated(res, req);
|
||||
if (!hasPermission) return;
|
||||
|
||||
if (!playerID) return res.cork(() => res.writeStatus("400").end("Missing player id"));
|
||||
|
||||
const player = Game.players[playerID];
|
||||
if (!player) return res.cork(() => res.writeStatus("400").end("Unknown player"));
|
||||
|
||||
player.disconnect();
|
||||
|
||||
res.cork(() => res
|
||||
.writeStatus("200")
|
||||
.end("Player has been disconnected"));
|
||||
};
|
||||
Reference in New Issue
Block a user