Hokm Multiplayer Setup Guide | FarsiRadio.com

پرش به محتوای اصلی
🎵 فارسی رادیو FarsiRadio.com - بیش از 30 ایستگاه رادیویی فارسی | رادیو فردا، ایران اینترنشنال، رادیو یار، رادیو شادی | موسیقی ایرانی، اخبار فارسی، برنامه‌های گفتگو | بهترین رادیوهای ایرانی آنلاین - گوش دادن زنده و رایگان | Persian Radio Online - Live Iranian Radio Stations
اشتراک
Back to FarsiRadio
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)

  1. Sign up: Create a free account at render.com . Connect your GitHub account when prompted.
  2. Put server.js on GitHub: Create a new public repo (e.g. hokm-royale-server) with just the server.js file and a package.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" }
    }
  3. 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
  4. Bind the port: Render sets process.env.PORT. Make sure server.js listens on it (not hardcoded 8000):
    const PORT = process.env.PORT || 8000;
    server.listen(PORT, () => console.log('Hokm server on', PORT));
  5. Deploy & grab the URL: Render gives you an HTTPS URL like https://hokm-royale.onrender.com. Your WebSocket URL is the same host with wss:// and /ws:
    wss://hokm-royale.onrender.com/ws
  6. 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:

  1. Play vs CPU (built-in, no server): Works right now. Three AI opponents, offline-capable, zero setup. Recommended for the majority of players.
  2. 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.
  3. Deploy server.js anywhere (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.
  4. 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.