update port & host

This commit is contained in:
Elizabeth Hunt 2023-09-02 18:00:28 -06:00
parent 19bea535ec
commit c370d02ed7
Signed by: simponic
GPG Key ID: 52B3774857EB24B1
3 changed files with 6 additions and 4 deletions

View File

@ -7,7 +7,7 @@ services:
networks: networks:
- webapp - webapp
ports: ports:
- 1337:80 - 28303:80
restart: always restart: always
container_name: jumpstorm-client container_name: jumpstorm-client
hostname: client hostname: client

View File

@ -1,4 +1,5 @@
export namespace Constants { export namespace Constants {
export const HOST = '0.0.0.0';
export const SERVER_PORT = 8080; export const SERVER_PORT = 8080;
export const SERVER_TICK_RATE = (1 / 120) * 1000; export const SERVER_TICK_RATE = (1 / 120) * 1000;
export const GAME_TOPIC = 'game'; export const GAME_TOPIC = 'game';

View File

@ -38,6 +38,7 @@ export class GameServer {
public serve() { public serve() {
if (!this.server) if (!this.server)
this.server = Bun.serve<SessionData>({ this.server = Bun.serve<SessionData>({
host: Constants.HOST,
port: Constants.SERVER_PORT, port: Constants.SERVER_PORT,
fetch: (req, srv) => this.fetchHandler(req, srv), fetch: (req, srv) => this.fetchHandler(req, srv),
websocket: { websocket: {
@ -137,7 +138,7 @@ export class GameServer {
const headers = new Headers(); const headers = new Headers();
headers.set('Access-Control-Allow-Origin', '*'); headers.set('Access-Control-Allow-Origin', '*');
if (url.pathname == '/assign') { if (url.pathname === '/api/assign') {
if (this.sessionManager.numSessions() > Constants.MAX_PLAYERS) if (this.sessionManager.numSessions() > Constants.MAX_PLAYERS)
return new Response('too many players', { headers, status: 400 }); return new Response('too many players', { headers, status: 400 });
@ -154,7 +155,7 @@ export class GameServer {
const sessionId = cookie.split(';').at(0)!.split('SessionId=').at(1); const sessionId = cookie.split(';').at(0)!.split('SessionId=').at(1);
if (url.pathname == '/game') { if (url.pathname === '/api/game') {
server.upgrade(req, { server.upgrade(req, {
headers, headers,
data: { data: {
@ -165,7 +166,7 @@ export class GameServer {
return new Response('upgraded to ws', { headers }); return new Response('upgraded to ws', { headers });
} }
if (url.pathname == '/me') { if (url.pathname === '/api/me') {
return new Response(sessionId, { headers }); return new Response(sessionId, { headers });
} }