mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-21 19:46:43 +00:00
attempt to fix public lobbies
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
</svg>
|
||||
</a>
|
||||
<h1 class="text-7xl sm:text-5xl md:text-6xl lg:text-7xl mb-2">OpenFront.io</h1>
|
||||
<h2 class="text-3xl sm:text-4xl md:text-5xl lg:text-6xl mb-4">(v0.8.0)</h2>
|
||||
<h2 class="text-3xl sm:text-4xl md:text-5xl lg:text-6xl mb-4">(v0.8.1)</h2>
|
||||
<div class="flex justify-center items-start">
|
||||
<div class="w-full max-w-3xl p-4 space-y-4">
|
||||
<username-input></username-input>
|
||||
|
||||
+15
-15
@@ -1,22 +1,22 @@
|
||||
import express, {json} from 'express';
|
||||
import express, { json } from 'express';
|
||||
import http from 'http';
|
||||
import {WebSocketServer} from 'ws';
|
||||
import { WebSocketServer } from 'ws';
|
||||
import path from 'path';
|
||||
import {fileURLToPath} from 'url';
|
||||
import {GameManager} from './GameManager';
|
||||
import {ClientMessage, ClientMessageSchema} from '../core/Schemas';
|
||||
import {getConfig} from '../core/configuration/Config';
|
||||
import {LogSeverity, slog} from './StructuredLog';
|
||||
import {Client} from './Client';
|
||||
import {GamePhase, GameServer} from './GameServer';
|
||||
import {v4 as uuidv4} from 'uuid';
|
||||
import { fileURLToPath } from 'url';
|
||||
import { GameManager } from './GameManager';
|
||||
import { ClientMessage, ClientMessageSchema } from '../core/Schemas';
|
||||
import { getConfig } from '../core/configuration/Config';
|
||||
import { LogSeverity, slog } from './StructuredLog';
|
||||
import { Client } from './Client';
|
||||
import { GamePhase, GameServer } from './GameServer';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
const app = express();
|
||||
const server = http.createServer(app);
|
||||
const wss = new WebSocketServer({server});
|
||||
const wss = new WebSocketServer({ server });
|
||||
|
||||
// Serve static files from the 'out' directory
|
||||
app.use(express.static(path.join(__dirname, '../../out')));
|
||||
@@ -28,12 +28,12 @@ app.get('/lobbies', (req, res) => {
|
||||
const now = Date.now()
|
||||
res.json({
|
||||
lobbies: gm.gamesByPhase(GamePhase.Lobby)
|
||||
.map(g => ({id: g.id, msUntilStart: g.startTime() - now, numClients: g.numClients()}))
|
||||
// .sort((a, b) => a.startTime - b.startTime),
|
||||
.filter(g => g.isPublic)
|
||||
.map(g => ({ id: g.id, msUntilStart: g.startTime() - now, numClients: g.numClients() }))
|
||||
.sort((a, b) => a.msUntilStart - b.msUntilStart),
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
app.post('/private_lobby', (req, res) => {
|
||||
const id = gm.createPrivateGame()
|
||||
console.log('creating private lobby with id ${id}')
|
||||
@@ -49,7 +49,7 @@ app.post('/start_private_lobby/:id', (req, res) => {
|
||||
|
||||
app.put('/private_lobby/:id', (req, res) => {
|
||||
const lobbyID = req.params.id
|
||||
gm.updateGameConfig(lobbyID, {gameMap: req.body.gameMap, difficulty: req.body.difficulty})
|
||||
gm.updateGameConfig(lobbyID, { gameMap: req.body.gameMap, difficulty: req.body.difficulty })
|
||||
});
|
||||
|
||||
app.get('/lobby/:id/exists', (req, res) => {
|
||||
|
||||
Reference in New Issue
Block a user