all repos — xrxs @ f752f9deeb8baeee4745c4a5a9228760f44d49fe

experimental networked application/game server with 9p

added new aux types: SCOPE, RANDOM, GRANDOM; updated spec
Iris Lightshard nilix@nilfm.cc
PGP Signature
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEkFh6dA+k/6CXFXU4O3+8IhROY5gFAmD17oUACgkQO3+8IhRO
Y5iR7w/+IyN6zMvPbFmZik8G/gsEwEXZmwrI+Rd/Z5EeANbAvRQoV5vv16ovJZYk
WToMhslqlk131stVYHvXtQO0MynHrsXKxlpdKyEjnTdAhMZ9xijjI8OLo43IbKqI
WglNffzC3y9HwMunou0Ma4WBTrwEEKkhCHDcaRb2sQfRJhRmeACMtcvZIyidMj11
1HJnwtcVFZ4ppBqNXCP+SvtJ6UEPb1Okr73bCE34LhxLEzoiv150q8BwiCwBsC6A
bahM09eK67Lmkh+AAQKbmaZUtiPrKv32ckfcWOPv3JG/s0SPI5M4+1/NkTwPQ+2s
WH45OhQaGJuzUiBZ3Uz11GnU8Z95xNgywNFYl8V/kYNJO7iNRCujqAj7A3VSlzq5
AZfPaplWiYs2PrgsmZDa5/Oh3xDn9HnTK/jlUW6ucaUfpyvSVLaE6MgvPQU20Wyl
NkVRZLkY36WG+B5nciAoSj4XQV9af3JhrnFfo/Q729CH3oclfKkPtq2sELCX3Cxo
2nA9F/JTRq8xP1bCDpofG2EyLvXSQ5j0If2ii/vFGx8nYmr8W7ViRIf2I7tu7hLI
/x8gzN+k51vRZ5VP1szvhlAKQ+Q89PcAAGS4K0VN7VLakUyWXQ11F5VvJM/xUHlx
SdYmC9X1snW4d50AdA3Iv1KWzpTNnL+yKBUMbA/NAGF/STXYbDE=
=6RYM
-----END PGP SIGNATURE-----
commit

f752f9deeb8baeee4745c4a5a9228760f44d49fe

parent

e469044b23878803a9eab622c0261068476622fb

3 files changed, 33 insertions(+), 12 deletions(-)

jump to
M README.mdREADME.md

@@ -8,20 +8,18 @@ ## design

This is the working structure of the 9p filesystem: -* `/ctl`: Write-only control file for inputing system commands (should we check the /realms file for success or failure, or should we make ctl r/w and return success or failure of the current user's last command on read?) +* `/ctl`: Write-only control file for inputing system commands * `login PW`: Authenticate with `xrxs` -- password is hashed against realm password hash * `load CART`: Load a cartridge - * `create REALM`: Create a new realm (start a new game) - * `protect REALM PW`: Protect the realm with a password + * `create REALM`: Create a new realm (start a new game) -- must have a cartridge loaded + * `protect REALM PW`: Protect the realm with a password if not already. * `enter REALM`: Join an existing realm * `leave`: Leave the current realm - * `save`: Save the current universe to the realm (redundant? or force universe/realm to flush?) - * `reset`: Reset the cartridge (attempts to leave the realm, but doesn't save) * `unload`: Unload the cartridge * `/users`: Read-only; Self and others in the realm are readable from here, one per line. It contains only yourself before joining a realm. Your username on your machine is used as your username in `xrxs` -- if your name is taken, you will get an error on attaching. -* `/carts`: Available game/app cartridges for this server, read only; Carts are listed per line upon reading the file. It is backed by files on the server in a directory structure like `carts/<cart_name>/{<cart_name.rom>, data/}`. +* `/carts`: Available game/app cartridges for this server, read only; Carts are listed per line upon reading the file. It is backed by files on the server in a directory structure like `carts/<cart_name>/{<cart_name.rom>, data/, realms/}`. * `/slot`: After loading the cartridge, its ROM is read from here; Read-only.

@@ -29,14 +27,19 @@ * `/data/`: Any supporting data that comes with the cartridge will be found here; to serve different files to different users, perhaps all resources of one filetype should be concatenated (ie, one file for all sprite data, one file for all text data, one file for all sound data) and let the client read whatever offset/length they need; read only

* `/realms`: Open/saved realms, read-only. Realms and their associated universe are backed by real files on the server so that they can be preserved across service instantiations, in a directory structure like: `realms/<realm_name>/{realm, universe}`. Realms can either be solo, open, or protected; Open or protected realms can have limited member numbers. Depending on the cartridge, these settings can be user-managed or managed by the cartridge itself. Realms are listed per line upon reading the file like: `realmx 1 4 1`. `realmx` would be the name of the realm. The first number is number of members, second is member limit, third is 1 if protected, 0 if not. `0 1 1` represents a protected solo realm that is empty (saved game with password). `0 1 0` represents an unprotected solo realm that is empty (saved game with no password). -* `/universe`: Write here to update serverside state for this cart/realm; Read from here to get the current state. Each cartridge will have its own format for encoding data here. Since this changes frequently in multiplayer games, perhaps only flush to disk at regular intervals instead of after every write. +* `/universe`: Write here to update serverside state for this cart/realm; Read from here to get the complete current state. This is backed by a key-value-pair list on the server. + +* `/scope`: Write here to tell the server the names of the `Atom`s (key/value pair of a `Universe`) you're interested in (one per line), and read from here to retrieve their values (one per line). In many cases this will be preferrable to fetching the entire `Universe`. +* `/random`: Read-only, get a random number from 0 to 99. + +* `/grandom`: Read-only, get a random number from 0 to 99 -- These are doled out on a per-realm basis, and the number stays the same until everyone in the realm has had a chance to read it. If you've already read it this round or aren't in a realm, it will be empty. + ## realm format Each realm directory on the server should have the following files: - * `realm`: Basic data for the realm, file should contain only the maximum number of members, and the password hash, if any, separated by a space. - * `members`: Members currently in the realm, one per line. - * `universe`: The actual game state in for the realm, format is cartridge-specific. + * `realm`: Basic data for the realm, file should contain only the maximum number of members, and the password hash, if any, separated by a space + * `universe`: The actual game state in for the realm, key value pairs, one per line, as "key = value"; limit 15 characters for keys, 63 for values. -Everything in the realm directory is synchronized to disc both when realm membership, limit, or password changes, and at regular intervals. If a member makes no writes to the universe after a certain time, consider them gone from the realm (so there should be a common SYN message all cartridges implement to keep them alive in the realm).+The realm should be synchronized to disc when realm membership, limit, or password change. Fenagling some periodic autosave should be possible...
M aux.haux.h

@@ -7,7 +7,10 @@ SPRITE_DATA,

AUDIO_DATA, TEXT_DATA, REALMS, - UNIVERSE + UNIVERSE, + SCOPE, + RANDOM, + GRANDOM, } FileType; typedef struct Aux {
M xrxs.cxrxs.c

@@ -189,6 +189,8 @@ break;

case UNIVERSE: write_universe(r); break; + case SCOPE: + // write_scope(r); default: respond(r, nil); break;

@@ -365,6 +367,15 @@ break;

case UNIVERSE: // read_universe(r); break; + case SCOPE: + // read_scope(r); + break; + case RANDOM: + // read_random(r); + break; + case GRANDOM: + // read_grandom(r); + break; default: respond(r, nil); break;

@@ -447,6 +458,10 @@ "universe",

nil, DMAPPEND | 0600, create_aux(UNIVERSE))); + closefile( + createfile(tree->root, "scope", nil, DMAPPEND | 0600, create_aux(SCOPE))); + closefile(createfile(tree->root, "random", nil, 0400, create_aux(RANDOM))); + closefile(createfile(tree->root, "grandom", nil, 0400, create_aux(GRANDOM))); if (argc >= 3) { if (mtpt != nil && access(mtpt, AEXIST) < 0 && access(mtpt, AEXIST) < 0)