Multiplayer for self-hosted copies: sessions, server-side saves, a leaderboard
Off unless the page is built with MP_API set (MP_API=/api/mp npm run build): a plain build has no door, no chip and makes no requests. The session server is scripts/mp-server.js (npm run mp), plain node:http, which can also serve the built site so one process sits behind the reverse proxy; docs/MULTIPLAYER.md has the nginx and Caddy setups. A session has a six-character code, one seed and one rules preset, so every player starts in the same world, and up to twelve players with their own AS numbers. Saves go to the server on a new game day at most every 15 s and when the page hides, ordered by a sequence number (409 on a stale push, and the player picks which one to keep). Tokens live in localStorage, never in the save; the server keeps only their hash. A #mp= link moves a network to another device. The session panel shows the leaderboard, the feed and a short chat; each player's public card (tier, POPs, links, exchanges, transit, peak, customers, score) carries what in-game peering between players will need next. Server limits: body sizes, one upload per player, uploads per address and in total, sessions per hour, wrong-code lockout; addresses counted per IPv6 /64, X-Forwarded-For only with --trust-proxy.
This commit is contained in:
parent
2b48a6ad65
commit
95aa9b6532
39 changed files with 2757 additions and 24 deletions
|
|
@ -600,6 +600,7 @@ const API_WHY={
|
|||
time:'use advance to move time, or wait when the clock runs on its own',start:'use new_game',files:'use load_save or export_save',
|
||||
slots:'saved networks in browser storage are not part of this game',prefs:'device and player settings are not part of the game',
|
||||
browser:'it needs the browser itself (a share sheet, the clipboard, an install prompt or a reload)',
|
||||
mp:'multiplayer talks to a session server for the player: only the player starts, joins, chats in or leaves a session',
|
||||
};
|
||||
const API_DENY={
|
||||
speed:'time',phonePlay:'time',phoneSpeed:'time',
|
||||
|
|
@ -607,5 +608,6 @@ const API_DENY={
|
|||
exportSave:'files',importGo:'files',importPick:'files',slotExport:'files',
|
||||
slotBack:'slots',slotDel:'slots',slotDelGo:'slots',slotMenu:'slots',slotRetry:'slots',slotSpace:'slots',slotSwitch:'slots',slotTake:'slots',
|
||||
animSet:'prefs',langSet:'prefs',mapSet:'prefs',menu:'prefs',mute:'prefs',prefSet:'prefs',settings:'prefs',settingsClose:'prefs',soundSet:'prefs',vpSet:'prefs',
|
||||
mpDoor:'mp',mpBack:'mp',mpStart:'mp',mpJoin:'mp',mpOpen:'mp',mpShare:'mp',mpCopyLink:'mp',mpChat:'mp',mpLeaveAsk:'mp',mpLeave:'mp',mpNewer:'mp',mpKeep:'mp',
|
||||
install:'browser',share:'browser',shareDl:'browser',shareGo:'browser',traceCopy:'browser',updateLater:'browser',updateNow:'browser',wsShare:'browser',pzShare:'browser',
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue