diff options
| author | eunhhu <[email protected]> | 2026-09-27 19:42:23 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-27 19:42:23 +0100 |
| commit | c20c8fa13c77d08d093aede126a1ec7646da0905 (patch) | |
| tree | 4d0a20dbe47e73a0297d5e21af30aced505498e4 /examples | |
| parent | a3c24ecbc00b04eaf191f8e16b8e53db57b4caeb (diff) | |
| download | vega-c20c8fa13c77d08d093aede126a1ec7646da0905.tar.gz vega-c20c8fa13c77d08d093aede126a1ec7646da0905.zip | |
Add a messenger between two nodes, sealed end to end
examples/messenger.aup keeps the lines typed here and sends each to the
other node, and keeps the other's. The check runs Alice's and Bob's
nodes, each with a key of its own, sealing to the other's and taking
lines only from the other (pure-serve --key, --send, --seal, --sender),
each drawn by Vega in the node, with a relay between them: a line typed
on Alice's display reaches Bob's node and is drawn on his, Bob's answer
posted by a program is drawn on hers, each last frame is the one the
vega command draws from that node's store, and the relay saw no line's
text nor a field's name, only one sealed session each way naming the
sender's key.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/messenger.aup | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/examples/messenger.aup b/examples/messenger.aup new file mode 100644 index 0000000..af513a1 --- /dev/null +++ b/examples/messenger.aup @@ -0,0 +1,55 @@ +# A messenger between two nodes. A line typed here is kept and goes to the +# other node; the other node's lines come here; all stay in order. Each node +# runs it with a key of its own, seals to the other's key, and takes lines +# only from the other, by name and key (pure-serve --key, --send, --seal, +# --sender): what passes between them is sealed end to end, and nothing on +# the way can read or change it. People type on the node's display (Vega in +# the node, pure-serve --surface); programs use the same node over HTTP. +use vega + +record Line { + from: text + body: text +} + +state lines: list of Line +state at: index of lines +state me: text = "me" + +input say = text +input up = key ArrowUp +input down = key ArrowDown +input rename = message { + name: text +} +input heard = message { + from: text + body: text +} +output said = message { + from: text + body: text +} + +on say { + lines.append(Line { from: me, body: say }) + at = lines.last + send said { from: me, body: say } +} +on heard { + lines.append(Line { from: heard.from, body: heard.body }) + at = lines.last +} +on rename { me = rename.name } +on up.down { at = at - 1 } +on down.down { at = at + 1 } + +view title = "{me}: {lines.count} lines" + +# A list: each line's text, who wrote it as its badge, the other's in accent. +view lines_list = each line in lines { + label = line.body + badge = line.from + tone = if line.from == me { vega.normal } else { vega.accent } +} +view lines_list_focus = at.position |
