wip
This commit is contained in:
parent
51c0c6cb1f
commit
2971b4c086
5 changed files with 17 additions and 13 deletions
6
.env
6
.env
|
|
@ -1,2 +1,6 @@
|
|||
PORT=3001
|
||||
ENVIRONMENT=local
|
||||
ENVIRONMENT=dev
|
||||
FRONTEND_URL=https://skyjo.voltvector.org
|
||||
|
||||
#ENVIRONMENT=local
|
||||
#FRONTEND_URL=http://localhost:5173
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -2,4 +2,6 @@ node_modules
|
|||
|
||||
dist
|
||||
|
||||
src/logs/
|
||||
src/logs/
|
||||
|
||||
.env.local
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>SkyJo Server list</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>SkyJo Server list</h1>
|
||||
<button>Start new Game</button>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -19,6 +19,9 @@ export const handleNewGame = (
|
|||
const { sessionId } = gameDetails;
|
||||
|
||||
const players = io.sockets.adapter.rooms.get(sessionId);
|
||||
// get players based on socket
|
||||
const playersInSession = io.sockets.adapter.sids.get(socket.id);
|
||||
console.log("Players in session:", playersInSession?.size);
|
||||
|
||||
if (players && players.size > 1) {
|
||||
const game = new Game(socket, sessionId, players);
|
||||
|
|
|
|||
|
|
@ -13,11 +13,15 @@ import corsOptions from "./config/corsOptions";
|
|||
import cookieParser from "cookie-parser";
|
||||
import rootRouter from "./routes/root";
|
||||
import { handleJoinSession, handleNewGame } from "./game/events";
|
||||
import dotenv from "dotenv";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
const FRONTEND_URL = process.env.FRONTEND_URL ?? "";
|
||||
const httpServer = new Server(app);
|
||||
export const io = new SocketIOServer(httpServer, {
|
||||
cors: {
|
||||
origin: "https://skyjo.voltvector.org",
|
||||
origin: FRONTEND_URL,
|
||||
methods: ["GET", "POST"],
|
||||
},
|
||||
});
|
||||
|
|
@ -36,6 +40,7 @@ io.on("connection", (socket: Socket) => {
|
|||
socket.on("disconnect", () => {
|
||||
console.log("A user disconnected:", socket.id);
|
||||
// TODO: remove players from session and delete game object
|
||||
io;
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue