[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7E6NJ2XP6XQDV3FT7XVF9FM":3,"skill-same:01M7E6NJ2XP6XQDV3FT7XVF9FM":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":6,"updatedAt":32,"install":33,"resources":46},"01M7E6NJ2XP6XQDV3FT7XVF9FM","servers",null,"Use when a Godot game hosts dedicated servers or its own matchmaker: running, stopping and health checks, join tokens, packet floods, matchmaking queues or chat moderation.","nick-vas\u002Fhyperdot","nick-vas","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F7181961?v=4","01M7E6F6F0BQ49V0JZHX9BXCBD","Nikolaos Vasilikiotis","01M7E6F6FZW8SW1AJ1S7ARFE89",1,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fnick-vas\u002Fhyperdot\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fservers\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: servers\ndescription: \"Use when a Godot game hosts dedicated servers or its own matchmaker: running, stopping and health checks, join tokens, packet floods, matchmaking queues or chat moderation.\"\n---\n\n# Dedicated servers and matchmaking (Godot 4.7, C#)\n\nWhat Google for Games' open-source Agones, Open Match, Quilkin and clean-chat (Apache-2.0) teach, without their cloud\nsetup, as tested C# in `${CLAUDE_PLUGIN_ROOT}\u002Fexamples\u002Fcsharp\u002Fsrc\u002FExample.Core\u002FNet\u002F` (tests next to the C# example's other\ntests). Netcode is `multiplayer`; sources and measurements are `${CLAUDE_PLUGIN_ROOT}\u002Fdocs\u002Fgoogleforgames.md`.\n\n## 1. Stopping: SIGTERM\n\nDocker (10 s), Kubernetes (30 s) and systemd (90 s) stop a process with SIGTERM, then kill it after the grace period.\n\n- Measured on 4.7.2: a headless Godot dies on SIGTERM or SIGINT at once, exit 143 or 130. No close-request\n  notification, no `_ExitTree`, nothing saved, even with `AutoAcceptQuit` off. GDScript cannot catch it, so a GDScript\n  server needs Godot .NET and one C# node with the handler.\n- In C#, .NET's handler catches it. Measured: the server below refused new players, drained and quit with 0 in 0.58 s.\n\n```csharp\nPosixSignalRegistration? _term;\nvolatile bool _stopRequested;\n\npublic override void _Ready() =>\n    \u002F\u002F Runs on a thread-pool thread: set a flag, act on it in the frame loop.\n    _term = PosixSignalRegistration.Create(PosixSignal.SIGTERM, ctx => { ctx.Cancel = true; _stopRequested = true; });\n\npublic override void _Process(double delta)\n{\n    if (_stopRequested) { _stopRequested = false; Act(_life.StopRequested(Now)); }   \u002F\u002F ServerLifecycle, section 2\n}\n```\n\n- `soak` sends the server SIGTERM at the end and reports `soak.stop` (`exitCode` 143: no handler);\n  `soak -RequireCleanStop` fails with `soak-unclean-stop`. The C# fixture is `${CLAUDE_PLUGIN_ROOT}\u002Ftests\u002Fsoak-fixture-cs`.\n\n## 2. A server's life\n\n`ServerLifecycle` decides and the host acts (`MarkReady`, `RefuseNewPlayers`, `MarkShutdown`, `Exit`):\n\n- Ready only once the port is bound: a server marked ready earlier sends players to a closed port.\n- One match per process: nothing from the last match leaks into the next (Agones' default). Reuse only after a full\n  reset, and only if starting is slow.\n- An allocated server nobody joins is given back after 15 minutes (`FirstPlayerTimeoutSeconds`); one everybody has left\n  ends after a short grace for reconnects (`EmptyGraceSeconds`, 20).\n- A stop during a match refuses new players and lets it run for `DrainSeconds` (20), below the host's grace period.\n- Health: ping every 2 s from a background task, against Agones' 5 s period times 3 failures. `HealthWatchdog` stops the\n  pings when the game loop has not run for 10 s, so a long load passes but a hung server is replaced.\n- Agones: `AgonesRest` speaks its HTTP SDK (`localhost:9358`, `AGONES_SDK_HTTP_PORT`) with `HttpClient`, no gRPC\n  packages. `sdk-server.linux.amd64 --local` runs the same endpoints on a laptop; checked here with 1.61.0. Set\n  `ExitAfterShutdown = false` there: Agones sends SIGTERM after `\u002Fshutdown`. Read the state back (`StateAsync`); calls\n  are asynchronous.\n- Your own orchestrator can serve the same endpoints (`POST \u002Fready`, `\u002Fhealth`, `\u002Fshutdown`, `GET \u002Fgameserver`).\n- Keep a buffer of ready servers. On fixed hosts (a VPS) spread matches across hosts; on hosts you can add and remove,\n  fill the busiest first so empty ones can go. Never kill an allocated server in a deploy: mark the old version and let\n  its matches drain.\n\n## 3. Who may join: join tokens\n\nThe matchmaker signs who may join which server; the server checks it in Godot's authentication step, before the peer\ncounts as connected. `JoinTokens` (HMAC-SHA256) issues; `JoinGate` admits once, before expiry, for this server only.\nThe secret lives on the matchmaker and the servers, never in the client.\n\n```csharp\nvar mp = (SceneMultiplayer)Multiplayer;\n\u002F\u002F Server: no PeerConnected until CompleteAuth; AuthTimeout (s) drops peers that never send a token.\nmp.AuthTimeout = 3;\nmp.AuthCallback = Callable.From\u003Cint, byte[]>((id, data) =>\n{\n    if (_gate.Admit(Encoding.UTF8.GetString(data), UnixNow, out _) == JoinVerdict.Accepted) mp.CompleteAuth(id);\n    else mp.DisconnectPeer(id);\n});\n\u002F\u002F Client: send the token when the server asks. The ids here are long.\nmp.AuthCallback = Callable.From\u003Cint, byte[]>((id, data) => { });\nmp.PeerAuthenticating += id => { mp.SendAuth((int)id, Encoding.UTF8.GetBytes(token)); mp.CompleteAuth((int)id); };\n```\n\nChecked on 4.7.2: the good token reached `PeerConnected`, and the bad one was disconnected without ever reaching it.\nThe refused client sees `ServerDisconnected`, not `ConnectionFailed`.\n\n## 4. Floods\n\n- Measured here: flooding a Godot 4.7.2 ENet server's port on loopback with junk UDP (`soak -JunkPps`) has no effect up\n  to ~10,000 packets a second, then collapses by ~50,000 (input loss ~38-57%, round trips into the seconds, dropped\n  clients). Well-written transports cope to ~250,000; Godot's single-threaded ENet poll sits well below that.\n- Inside Godot nothing runs before ENet: filter in the OS firewall (nftables, a per-address limit), in a proxy (Quilkin\n  drops packets without a known token), and against a flood that fills the link, at the provider's edge.\n- Keep no state for anyone who has not passed a check yet, and never answer an unchecked packet with more bytes than it\n  sent (a server query that replies bigger is an amplifier for attacks on others).\n- Limit by address, not address and port: a sender that changes its port gets a fresh budget otherwise. `RateLimiter`\n  is a token bucket per key (IP for connections, player for RPCs and chat) that forgets idle keys.\n- Count dropped packets by a fixed list of reasons (bad token, over the limit, too short), as Quilkin does.\n\n## 5. Matchmaking\n\n`Matchmaker` keeps Open Match's lessons in one loop:\n\n- One live ticket per player (a double click, a second device). Every ticket expires (`TicketTtlSeconds`, 600): Open\n  Match 1's tickets never did, and leaked.\n- Hard limits first: mode, then regions under `MaxPingMs` (120). Then the closest skills, with the allowed spread\n  widening by wait: 100 at once, 250 after 10 s, 600 after 30 s.\n- A proposal reserves its tickets. `Assign` once the server is ready and the clients told where (address and join\n  token); `Reject` puts them back with their age. A reservation never answered is released after 60 s.\n- Running matches' open slots (`PublishBackfill`) are filled before new matches start.\n- Simulated: at 10 players a second, median wait 0 s, longest 12 s, 90% of matches within 77 skill points. At 1 a\n  second: longest wait 27 s, 90% within 157. A quiet queue trades quality for waiting.\n\n## 6. Chat moderation\n\n`ChatGuard` follows clean-chat:\n\n- Score each message on the server (0 fine, 1 abuse). `WordListScorer` matches whole words, so \"Scunthorpe\" passes.\n- Act on the sender's average over 30 s, not on one message: warn, then mute (10 min), then a report a person reads.\n- One strike per crossing, or per window while it stays over the line.\n- Rate-limit first: a burst of 5, then one message every 2 s.\n- Decide what happens when the scorer fails (`FailClosed`), and log it.\n- Keep only reported excerpts, and delete them after review.\n\n## 7. Prove it\n\n- The C# example's `ServerLifecycleTests`, `JoinTokenTests`, `MatchmakerTests` (a 2,000-player crowd: no ticket used twice)\n  and `ChatGuardTests`.\n- `soak -RequireCleanStop` on the real server, and a junk flood with `soak -JunkPps`.\n","# Dedicated servers and matchmaking (Godot 4.7, C#)\n\nWhat Google for Games' open-source Agones, Open Match, Quilkin and clean-chat (Apache-2.0) teach, without their cloud\nsetup, as tested C# in `${CLAUDE_PLUGIN_ROOT}\u002Fexamples\u002Fcsharp\u002Fsrc\u002FExample.Core\u002FNet\u002F` (tests next to the C# example's other\ntests). Netcode is `multiplayer`; sources and measurements are `${CLAUDE_PLUGIN_ROOT}\u002Fdocs\u002Fgoogleforgames.md`.\n\n## 1. Stopping: SIGTERM\n\nDocker (10 s), Kubernetes (30 s) and systemd (90 s) stop a process with SIGTERM, then kill it after the grace period.\n\n- Measured on 4.7.2: a headless Godot dies on SIGTERM or SIGINT at once, exit 143 or 130. No close-request\n  notification, no `_ExitTree`, nothing saved, even with `AutoAcceptQuit` off. GDScript cannot catch it, so a GDScript\n  server needs Godot .NET and one C# node with the handler.\n- In C#, .NET's handler catches it. Measured: the server below refused new players, drained and quit with 0 in 0.58 s.\n\n```csharp\nPosixSignalRegistration? _term;\nvolatile bool _stopRequested;\n\npublic override void _Ready() =>\n    \u002F\u002F Runs on a thread-pool thread: set a flag, act on it in the frame loop.\n    _term = PosixSignalRegistration.Create(PosixSignal.SIGTERM, ctx => { ctx.Cancel = true; _stopRequested = true; });\n\npublic override void _Process(double delta)\n{\n    if (_stopRequested) { _stopRequested = false; Act(_life.StopRequested(Now)); }   \u002F\u002F ServerLifecycle, section 2\n}\n```\n\n- `soak` sends the server SIGTERM at the end and reports `soak.stop` (`exitCode` 143: no handler);\n  `soak -RequireCleanStop` fails with `soak-unclean-stop`. The C# fixture is `${CLAUDE_PLUGIN_ROOT}\u002Ftests\u002Fsoak-fixture-cs`.\n\n## 2. A server's life\n\n`ServerLifecycle` decides and the host acts (`MarkReady`, `RefuseNewPlayers`, `MarkShutdown`, `Exit`):\n\n- Ready only once the port is bound: a server marked ready earlier sends players to a closed port.\n- One match per process: nothing from the last match leaks into the next (Agones' default). Reuse only after a full\n  reset, and only if starting is slow.\n- An allocated server nobody joins is given back after 15 minutes (`FirstPlayerTimeoutSeconds`); one everybody has left\n  ends after a short grace for reconnects (`EmptyGraceSeconds`, 20).\n- A stop during a match refuses new players and lets it run for `DrainSeconds` (20), below the host's grace period.\n- Health: ping every 2 s from a background task, against Agones' 5 s period times 3 failures. `HealthWatchdog` stops the\n  pings when the game loop has not run for 10 s, so a long load passes but a hung server is replaced.\n- Agones: `AgonesRest` speaks its HTTP SDK (`localhost:9358`, `AGONES_SDK_HTTP_PORT`) with `HttpClient`, no gRPC\n  packages. `sdk-server.linux.amd64 --local` runs the same endpoints on a laptop; checked here with 1.61.0. Set\n  `ExitAfterShutdown = false` there: Agones sends SIGTERM after `\u002Fshutdown`. Read the state back (`StateAsync`); calls\n  are asynchronous.\n- Your own orchestrator can serve the same endpoints (`POST \u002Fready`, `\u002Fhealth`, `\u002Fshutdown`, `GET \u002Fgameserver`).\n- Keep a buffer of ready servers. On fixed hosts (a VPS) spread matches across hosts; on hosts you can add and remove,\n  fill the busiest first so empty ones can go. Never kill an allocated server in a deploy: mark the old version and let\n  its matches drain.\n\n## 3. Who may join: join tokens\n\nThe matchmaker signs who may join which server; the server checks it in Godot's authentication step, before the peer\ncounts as connected. `JoinTokens` (HMAC-SHA256) issues; `JoinGate` admits once, before expiry, for this server only.\nThe secret lives on the matchmaker and the servers, never in the client.\n\n```csharp\nvar mp = (SceneMultiplayer)Multiplayer;\n\u002F\u002F Server: no PeerConnected until CompleteAuth; AuthTimeout (s) drops peers that never send a token.\nmp.AuthTimeout = 3;\nmp.AuthCallback = Callable.From\u003Cint, byte[]>((id, data) =>\n{\n    if (_gate.Admit(Encoding.UTF8.GetString(data), UnixNow, out _) == JoinVerdict.Accepted) mp.CompleteAuth(id);\n    else mp.DisconnectPeer(id);\n});\n\u002F\u002F Client: send the token when the server asks. The ids here are long.\nmp.AuthCallback = Callable.From\u003Cint, byte[]>((id, data) => { });\nmp.PeerAuthenticating += id => { mp.SendAuth((int)id, Encoding.UTF8.GetBytes(token)); mp.CompleteAuth((int)id); };\n```\n\nChecked on 4.7.2: the good token reached `PeerConnected`, and the bad one was disconnected without ever reaching it.\nThe refused client sees `ServerDisconnected`, not `ConnectionFailed`.\n\n## 4. Floods\n\n- Measured here: flooding a Godot 4.7.2 ENet server's port on loopback with junk UDP (`soak -JunkPps`) has no effect up\n  to ~10,000 packets a second, then collapses by ~50,000 (input loss ~38-57%, round trips into the seconds, dropped\n  clients). Well-written transports cope to ~250,000; Godot's single-threaded ENet poll sits well below that.\n- Inside Godot nothing runs before ENet: filter in the OS firewall (nftables, a per-address limit), in a proxy (Quilkin\n  drops packets without a known token), and against a flood that fills the link, at the provider's edge.\n- Keep no state for anyone who has not passed a check yet, and never answer an unchecked packet with more bytes than it\n  sent (a server query that replies bigger is an amplifier for attacks on others).\n- Limit by address, not address and port: a sender that changes its port gets a fresh budget otherwise. `RateLimiter`\n  is a token bucket per key (IP for connections, player for RPCs and chat) that forgets idle keys.\n- Count dropped packets by a fixed list of reasons (bad token, over the limit, too short), as Quilkin does.\n\n## 5. Matchmaking\n\n`Matchmaker` keeps Open Match's lessons in one loop:\n\n- One live ticket per player (a double click, a second device). Every ticket expires (`TicketTtlSeconds`, 600): Open\n  Match 1's tickets never did, and leaked.\n- Hard limits first: mode, then regions under `MaxPingMs` (120). Then the closest skills, with the allowed spread\n  widening by wait: 100 at once, 250 after 10 s, 600 after 30 s.\n- A proposal reserves its tickets. `Assign` once the server is ready and the clients told where (address and join\n  token); `Reject` puts them back with their age. A reservation never answered is released after 60 s.\n- Running matches' open slots (`PublishBackfill`) are filled before new matches start.\n- Simulated: at 10 players a second, median wait 0 s, longest 12 s, 90% of matches within 77 skill points. At 1 a\n  second: longest wait 27 s, 90% within 157. A quiet queue trades quality for waiting.\n\n## 6. Chat moderation\n\n`ChatGuard` follows clean-chat:\n\n- Score each message on the server (0 fine, 1 abuse). `WordListScorer` matches whole words, so \"Scunthorpe\" passes.\n- Act on the sender's average over 30 s, not on one message: warn, then mute (10 min), then a report a person reads.\n- One strike per crossing, or per window while it stays over the line.\n- Rate-limit first: a burst of 5, then one message every 2 s.\n- Decide what happens when the scorer fails (`FailClosed`), and log it.\n- Keep only reported excerpts, and delete them after review.\n\n## 7. Prove it\n\n- The C# example's `ServerLifecycleTests`, `JoinTokenTests`, `MatchmakerTests` (a 2,000-player crowd: no ticket used twice)\n  and `ChatGuardTests`.\n- `soak -RequireCleanStop` on the real server, and a junk flood with `soak -JunkPps`.\n",{"name":5,"description":7},"main","5fa4c2262d814d50f72198a95b8c483ff195f90f",".agents\u002Fskills\u002Fservers",0,"https:\u002F\u002Fgithub.com\u002Fnick-vas\u002Fhyperdot","https:\u002F\u002Fnick-vas.github.io\u002Fhyperdot\u002F","https:\u002F\u002Fgithub.com\u002Fnick-vas","https:\u002F\u002Fcommon-beef.itch.io\u002F","2026-11-13 18:55:29",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add nick-vas\u002Fhyperdot --skill servers",{"tool":39,"command":40},"bunx","bunx skills add nick-vas\u002Fhyperdot --skill servers",{"tool":42,"command":43},"pnpm","pnpm dlx skills add nick-vas\u002Fhyperdot --skill servers","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fnick-vas\u002Fhyperdot\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fservers\u002FSKILL.md",true,[],[48,55,61,68,75,82],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M7E6RF2S03S92PB9RZB4S4W0","over-budget","Use when a fixture exceeds the size budget.","https:\u002F\u002Fgithub.com\u002Fnick-vas\u002Fhyperdot\u002Fblob\u002Fmain\u002Ftests\u002Fskill-fixtures\u002Fover-budget\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":19},"01M7E6RBY8SDNMA3ZARE8MAH0G","bad-yaml","https:\u002F\u002Fgithub.com\u002Fnick-vas\u002Fhyperdot\u002Fblob\u002Fmain\u002Ftests\u002Fskill-fixtures\u002Fbad-yaml\u002FSKILL.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":19},"01M7E6R9S9YHTC552SR41RQAJ1","bad-workflow-description","Use when testing; runs the kit and then reads the JSON.","https:\u002F\u002Fgithub.com\u002Fnick-vas\u002Fhyperdot\u002Fblob\u002Fmain\u002Ftests\u002Fskill-fixtures\u002Fbad-workflow-description\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M7E6R6CWSAN48C80130CM1AK","bad-version","Use when a fixture quotes a stale package version.","https:\u002F\u002Fgithub.com\u002Fnick-vas\u002Fhyperdot\u002Fblob\u002Fmain\u002Ftests\u002Fskill-fixtures\u002Fbad-version\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M7E6R2C0E24TC133ESHKZT9R","bad-value","Use when a fixture passes a value outside a parameter's set.","https:\u002F\u002Fgithub.com\u002Fnick-vas\u002Fhyperdot\u002Fblob\u002Fmain\u002Ftests\u002Fskill-fixtures\u002Fbad-value\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M7E6QYM81V061X7DSQ94CZRP","bad-trigger","Helps with Godot tests.","https:\u002F\u002Fgithub.com\u002Fnick-vas\u002Fhyperdot\u002Fblob\u002Fmain\u002Ftests\u002Fskill-fixtures\u002Fbad-trigger\u002FSKILL.md",[],[]]