-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
29 lines (23 loc) · 817 Bytes
/
server.js
File metadata and controls
29 lines (23 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const express = require('express');
const http = require('http');
const socketIo = require('socket.io');
// Import server components
const { setupRoutes } = require('./server_logic/routes');
const { setupSocketHandlers } = require('./server_logic/socket_handlers');
const { startGameLoop } = require('./server_logic/game_loop');
// Create Express app and HTTP server
const app = express();
const server = http.createServer(app);
const io = socketIo(server);
// Setup routes
setupRoutes(app);
// Setup WebSocket handlers
setupSocketHandlers(io);
// Start the game loop
startGameLoop(io);
// Start the server
const PORT = process.env.PORT || 3000;
server.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
console.log(`WebSocket server is also running on the same port`);
});