Skip to content

Master#7

Merged
anshggss merged 14 commits into
mainfrom
master
Jul 4, 2026
Merged

Master#7
anshggss merged 14 commits into
mainfrom
master

Conversation

@anshggss

@anshggss anshggss commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Closes #1

Copilot AI review requested due to automatic review settings July 4, 2026 12:12
@vercel

vercel Bot commented Jul 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
box-game-client Ready Ready Preview, Comment Jul 4, 2026 12:12pm

@anshggss anshggss merged commit a6125a2 into main Jul 4, 2026
4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Implements infrastructure and client/server changes to support a gateway-driven, multi-server deployment where clients obtain an assigned game-server endpoint from the gateway and connect over TLS via an Nginx stream proxy + port-range mapping.

Changes:

  • Game-server: initialize rooms defensively on create, add a /status endpoint, and add dynamic port-range selection + server-manager registration retry loop.
  • Gateway/client: switch room allocation/join flow to JSON responses (host/port/roomID) and update the client to connect to the assigned game-server endpoint.
  • Ops: add host-level Nginx stream config + generator script, and update Kubernetes manifests for gateway exposure and game-server port range settings.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
server/server.ts Adds room initialization, status endpoint behavior, port-range selection, and resilient registration with server-manager.
server/Dockerfile Switches runtime base image to node:lts-slim.
server-manager/index.ts Removes CORS middleware and binds to 0.0.0.0.
scripts/gen-stream-ports.sh Generates Nginx stream port blocks for external→internal port mapping.
nginx-gameserver-stream.conf Documents and configures host-level TLS termination + stream forwarding for game servers.
k8s.yaml Updates gateway env/service exposure and configures game-server port-range env + ingress/cert-manager resources.
gateway/routes/createRoom.ts Allocates room, fetches server assignment with retry, and returns JSON connection details.
gateway/routes/addToRoom.ts Returns JSON connection details for joining an existing room.
gateway/index.ts Updates CORS origin configuration and logs allowed origins.
client/styles.css Updates landing/lobby styling and UI layout.
client/index.js Updates gateway interaction and socket connection flow using JSON room assignment.
client/index.html Updates lobby UI markup and sets production window.GATEWAY_URL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread client/index.js
Comment on lines +132 to 134
connectSocket(`${WS_SCHEME}://${hostIp}:${port}`, () => {
socket.emit("joinRoom", { name: pName, roomID }, (ack) => {
setLobbyLoading(false);
Comment thread client/index.js
Comment on lines +6 to +13
const GATEWAY_URL = window.GATEWAY_URL;

// In production the game-server domain is server.boxgame.shadyggs.xyz.
// Nginx terminates TLS for wss://server.boxgame.shadyggs.xyz:<port> and
// forwards to the hostNetwork pod on the same port.
// In local dev the cookie will contain "localhost" so http:// is used.
const isLocalDev = GATEWAY_URL.startsWith("http://");
const WS_SCHEME = isLocalDev ? "http" : "wss";
Comment on lines 45 to +49
const serverManager = process.env.SERVER_MANAGER_URL;

try {
// Get assigned a server
const response = await fetch(`${serverManager}/assign`);
const response = await fetchWithRetry(`${serverManager}/assign`);
Comment on lines +65 to +68
const INTERNAL_TO_EXTERNAL_OFFSET = 10000;
const internalPort = Number(response.headers.get("port"));
const externalPort = internalPort - INTERNAL_TO_EXTERNAL_OFFSET;

Comment on lines +5 to +11
// Cross-site cookie options required for Vercel (HTTPS) → VM (different origin).
// SameSite=None + Secure is mandatory for browsers to send cookies cross-site.
const COOKIE_OPTS = {
sameSite: "none" as const,
secure: true,
httpOnly: false, // client JS must read these values
};
Comment on lines +4 to +9
// Cross-site cookie options – must match createRoom.ts
const COOKIE_OPTS = {
sameSite: "none" as const,
secure: true,
httpOnly: false,
};
Comment thread gateway/index.ts
Comment on lines +12 to +16
const allowedOrigin = [
"https://gateway.boxgame.shadyggs.xyz",
"http://localhost:4689",
"https://boxgame.shadyggs.xyz",
];
Comment thread k8s.yaml
Comment on lines 177 to +179
# Talk to server-manager inside the cluster
- name: SERVER_MANAGER_URL
value: "http://server-manager-svc.box-game.svc.cluster.local:4689"
value: "http://10.99.57.238:4689"
Comment thread k8s.yaml
Comment on lines 336 to +337
- name: SERVER_MANAGER_URL
value: "http://server-manager-svc.box-game.svc.cluster.local:4689"
# No fixed containerPort – the server calls listen(0) for a random port
value: "http://10.99.57.238:4689"
Comment thread client/styles.css
Comment on lines +104 to 105
.nameBox:hover::before{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Scalable Multi-Server Architecture with Gateway-Based Room Allocation

2 participants