| ParlorNet Turn-based game server for any computer, old or new | |
| Clients | Protocols | Browsers | Telnet programs | Docs | Source |
A plugin is a program the server talks to over stdin/stdout, one JSON object per line, shared by all tables of its type. Calls are stateless, so a crashed or restarted plugin loses nothing. (JSON is fine here: both ends are modern machines. The 8-bit-facing protocol is in protocol.md.)
Each game is a directory under plugins/ holding one of:
A plugin.py runs in a process of its own, python3 plugin.py, like an executable, when its info has "process": "own", when it has no OPS table, or when the host cannot get its info. Every shipped plugin is hosted, and each still runs alone with python3 plugin.py.
The core asks every plugin for its info once, at start-up (one start of the host for all the Python plugins, one start of each plugin of its own), and keeps it: listing the games (GAM) and creating tables need no running process. A process is started on the first call that needs it and stopped once it has had no call for plugins.idle seconds (default 600; the setting, from the admin store or the settings file, or --plugin-idle on parlord's command line) while no table of its games is being played. A call that fails, or gets no reply within 5 seconds, kills the process (the host, for a hosted plugin) and is tried once more in a new one.
Server to plugin, each answered by one line. Every request for a table carries "rules" (the table's ruleset name from the plugin's info), so a plugin with several rulesets knows which one applies; new also carries "players" (the table's seat count, from the game's minimum to its maximum, chosen with players=n on NEW).
| Request | Reply | |
|---|---|---|
| {"op":"info"} | {"id","name","min","max","options":[...],"flags":[...],"views":{...}}, and "process":"own" for a plugin.py that needs a process of its own | |
| {"op":"new","players":n,"options":{},"seed":int} | {"state":...} | |
| {"op":"view","state","seat"} | {"wire":[view lines],"geometry":[static lines],"status":text,"data":{...}}: the type's view lines in wire form, plus the same state as JSON for modern clients | |
| {"op":"moves","state","seat"} | {"moves":[token lists]} or {"check":true} for huge move sets | |
| {"op":"apply","state","seat","move":[tokens],"check":bool} | {"state","events":[wire event text],"end":result?} or {"error":"reason"}; with check nothing is changed and {"info"} is returned | |
| {"op":"result","state"} | {"over":false} or {"over":true,"scores":[...]} | |
| `{"op":"drop","state","seat","why":"resign"\ | "timeout"}` | Only for a plugin with the flag drop: one seat leaves a running game and the others play on. Answered like apply: {"state","events","end"?} (the events include GONE seat why; end when one seat is left), or {"error"} |
Flags in info: staged (turns of several steps, UND/END), nomoves (no move list; clients use CHK), drop (the plugin answers drop). The core calls drop when a player resigns (RES) or runs out of time while more than two seats are still playing; it records the seat as gone (no more MOV or RES from it) and keeps the table running. With two seats left, or when drop answers an error, the game ends for everyone as for any other game (END resign seat, END timeout seat).
Rules:
| These pages cover every ParlorNet server. | Source code | ParlorNet is free software. |