اشتراک
Your multiplayer server
No server set — CPU mode only
Use wss:// for hosted servers (required by HTTPS pages). You can also override per-visit with ?hokmServer=wss://....
Deploy on Render (5 minutes)
- Sign up: Create a free account at render.com . Connect your GitHub account when prompted.
- Put
server.json GitHub: Create a new public repo (e.g.hokm-royale-server) with just theserver.jsfile and apackage.json:{ "name": "hokm-royale-server", "version": "1.0.0", "main": "server.js", "engines": { "node": ">=18" }, "scripts": { "start": "node server.js" }, "dependencies": { "ws": "^8.16.0" } } - Create the Render service: In Render, click New → Web Service, select your repo, and use these settings:
- Environment: Node
- Build Command:
npm install - Start Command:
node server.js - Instance Type: Free
- Region: pick the one closest to your players
- Bind the port: Render sets
process.env.PORT. Make sureserver.jslistens on it (not hardcoded 8000):const PORT = process.env.PORT || 8000; server.listen(PORT, () => console.log('Hokm server on', PORT)); - Deploy & grab the URL: Render gives you an HTTPS URL like
https://hokm-royale.onrender.com. Your WebSocket URL is the same host withwss://and/ws:wss://hokm-royale.onrender.com/ws
- Paste it above in the input field and click Save. Play Hokm → “Online” → you'll queue against real players.
⚠️ Render free tier notes
- Free services sleep after 15 minutes of inactivity — first connection takes ~30s to wake.
- Upgrade to the $7/mo Starter plan to keep the server always-on for smoother matchmaking.
- WebSocket connections stay open freely — Render doesn't count them against request limits.
Can we skip the outside server?
A real-time 4-player card game needs a persistent WebSocket process to relay moves between all players' browsers. Lovable/Supabase edge functions are stateless and time out after ~30s, so they can't hold a live game session. Here are the workaround options in order of effort:
- Play vs CPU (built-in, no server): Works right now. Three AI opponents, offline-capable, zero setup. Recommended for the majority of players.
- Supabase Realtime channels (broker-only, still needs client trust): We could rewrite the multiplayer layer to use Supabase Realtime as a pub/sub broker — no external server. Downside: game state has to live in the browser, so cheating is possible. Good for friend games, bad for a public queue. ~2–3 days of work.
- Deploy
server.jsanywhere (Render / Railway / Fly.io / Cloudflare Workers Durable Objects):This guide covers Render because the free tier is the simplest. Fly.io and Railway have equivalent flows. - Peer-to-peer WebRTC: Direct player-to-player. Removes server hosting entirely but needs a signaling endpoint (Supabase Realtime works) and NAT traversal (STUN/TURN). Major rewrite.
Hokm Royale is an exclusive FarsiRadio product. Server source (
server.js) is included in your admin bundle.