Differences From
Artifact [13ce85cdbb]:
17 17 * [*sigint<[$N]>] ==> like the above, but interpreted as a two's-complement signed integer
18 18 * [*byte-sequence<[$L]>] ==> [!int<[$L]>:[$N]] [!byte<[$N]>], with no specific semantics. that is, a variable-length byte sequence whose size prefix is [$L] bits long
19 19 * [*string] ==> [!byte-sequence<8>] interpreted as a UTF-8 string
20 20 * [*text] ==> [!byte-sequence<16>] interpreted as a UTF-8 string
21 21 * [*bitmap] ==> [!int<16>:[$pxl-width]] [!byte-sequence<8>:[$map]]
22 22 * [*state] ==>
23 23 *: if on the root menu: [`0x00]
24 -*: if on a menu with an ID between [`1]-[`127] and the opaque [$ref] value is [`0] ("null"): the menu number cast to [!int<8>] (e.g. [`0x00 4A] --> [`0x4A])
25 -*: if on a menu between [`128]-[`383] with a null [$ref] value: [`0x80] [!int<8>:[=mode - 128]]
24 +*: if on a menu with an ID between [`1]~[`127] and the opaque [$ref] value is [`0] ("null"): the menu number cast to [!int<8>] (e.g. [`0x00 4A] --> [`0x4A])
25 +*: if on a menu between [`128]~[`383] with a null [$ref] value: [`0x80] [!int<8>:[=mode - 128]]
26 26 *: if on a menu greater than [`383] with a null [$ref]: [`0x81] [!int<16>:[$mode]]. this form is also valid if the number is lower than [`383], and can be used where logical simplicity is more important than compact signalling
27 27 *: otherwise:
28 28 *:: let [$ref-len] be the length in bytes of the [$ref] value, maximum 8 (0 is valid, in which case no [$ref] sequence is sent)
29 29 *:: let [$mode-range] be [`0] if [$mode] is between [`0] and [`255], [`1] otherwise
30 -*:: let [$signal-byte] be [`([$ref-len] << 1) | [$mode]-[$range]]
31 -*:: send [!int<8>:[$signal-byte]] [!int<[=8 + 8*mode-range]>:[$mode]] [!int<[$ref-len*8]>:[$ref]]
30 +*:: let [$signal-byte] be [`([$ref-len] << 1) | [$mode-range]]
31 +*:: send [!int<8>:[$signal-byte]] [!int<[`8 + 8*[$mode-range]]>:[$mode]] [!int<[`[$ref-len]*8]>:[$ref]]
32 32 * [*link] ==> [!int<8>:[$role]] [!state:[$target]]
33 33
34 34 ## outline
35 -
36 35 : client connects to server
37 36 : client transmits {m.n con-ack}
38 -: client authenticates by one of the following
39 -:: to authenticate anonymously, client transmits byte [`0x00].
40 -:: to authenticate by shortname, client transmits byte [`0x01] followed by a [!byte-sequence<8>]. this may be a PSK, a URI, a literal text name, an OID, or anything else depending on what the server is configured to recognize.
41 -:: to authenticate by longname, client transmits byte [`0x01] followed by a [!byte-sequence<16>]. this is identical to the above but allows to longer values. technically these are different forms of the "name" authentication method; the difference is relevant only at the byte-level
42 -:: other authentication methods may be defined later. a server that encounters an unknown authentication method must transmit an error and close the connection, as it cannot know how to interpret any further communications from the client
43 -: server reports authentication status
44 -:: if the authentication failed, xmit {m.n status-fail} and close the connection
45 -:: if the authentication succeeded, xmit {m.n status-ok}
37 +: server responds {m.n status-ok}
38 +: client and server authenticate using the [>nimtas authentication protocol]. for an anonymous connection, this is as simple as the dialogue “C: [`0x00] / S: {m.n status-ok}”
46 39 : client transmits a command
47 40 :: {m.n cmd-get} retrieves a menu. it takes the form [!state] [!action]
48 41 :: {m.n cmd-hint} transmits a hint to the server. it takes the form [!int<8>:[$hint]] [!byte-sequence<16>]
49 42 :: {m.n cmd-meta} requests metadata from the server. it takes the form [!int<16>]
50 43 :: {m.n cmd-end} closes the connection. it takes no arguments
51 44 : server issues [>rep reply]
52 45 : while command was not {m.n cmd-end}, previous two steps repeat
53 46 : peers disconnect
47 + nimtas: file:nimtas.ct
48 +
54 49
55 50 ##rep server replies
56 51 all replies begin with a one-byte status code.
57 52
58 53 ### cmd-get reply
59 -the hint reply code may be:
54 +the get reply code may be:
60 55 * {m.n status-ok}: the request was valid but the current display should not be changed
61 56 * {m.n status-fail}: the request was not valid
62 57 * {m.n status-ignore}: the action did nothing
63 58 * {m.n status-data}: the request was valid and a form is being returned to display.
64 59
65 60 if the reply is {m.n status-data}, it is followed by the header [!byte:[$flags]] [!int<16>:[$widget-count]]
66 61 * [$flags] is a bitmask