all repos — xrxs @ 7ff7a1e29e5d87b155150e4f2c0bde82f4b127e5

experimental networked application/game server with 9p

DESIGN (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
[9p directory structure]
/ctl: write only control file for inputing system commands
  login NAME PW: authenticate with xrxs -- pw is hashed against realm pw hash
  load CART: load a cartridge
  create REALM: create a new realm (start a new game or app session)
  protect REALM: protect the realm with auth data
  enter REALM: join an existing realm
  leave: leave the current realm
  save: save the current universe to the realm
  reset: reset the cartridge (attempts to leave the realm, but doesn't save)
  unload: unload the cartridge
  
  should we check the /realms file for success or failure, or should we make ctl rw and return success or failure of the current user's last command on read?

/users: read-only; self and others in the realm are readable from here in the form:
  <AFID> <username>
  one per line;
  file is blank before login,
  contains only self before joining a realm

/carts: available game/app cartridges for this server, read only
  carts are listed per line upon reading the file
  backed by files on the server (carts/<cart_name>/{<cart_name.rom>, data/}
  
/slot: after loading the cartridge, its ROM is read from here; read only

/data/: any supporting data that comes with the cartridge will be found here; 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. (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
  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: read/write: write here to update serverside state for this cart/realm; read from here to get the current state.
  each cart 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
  
[Realm format]

each realm directory on the server should have the following files:
  realm: basic data for the realm. file contents should contain only the maximum number of members, and the password hash, if any, separated by a space
  members: members currently in the realm, in the form "<AFID> <username>", one per line
  universe: the actual game state in for the realm, format is cartridge-specific
  
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)