pub enum ClientMsg {
Hello {
sub: String,
seq: Option<Seq>,
actor: String,
path: String,
},
Cmd {
id: String,
command: Value,
},
Nav {
path: String,
},
Ping,
}Variants§
Hello
Subscribe, or resume.
seq is what this client holds, and its absence is meaningful: None is “I have
nothing, send me the world” and Some(n) is “I hold the frame as of n” — including
Some(0), which is what a browser says when the document it is running in was rendered
from an empty log. Those were the same message until a browser ran the thin client and the
first paint rebuilt the page it had just been served (docs/94 §94.13): position zero and
nothing-at-all are different facts, and a protocol that spells them the same way cannot
keep §5.1’s “first paint is free” promise.
Fields
actor: StringWhat the client says it is. A claim, not an actor: beck_rt::identity is what
turns it into one, and under DevIdentity the two are the same value — which is a
choice an operator makes rather than a property of the protocol (docs/48).
path: StringWhere this client is, as a route. Absent means the application’s root.
On the hello rather than only in a ClientMsg::Nav because a subscription is
re-established after every disconnection, and a client whose route were established by
a separate frame would render one page for as long as the two frames were in flight —
and would render the wrong page for as long as it took the second one to be resent
after a reload with the network down.
Cmd
A proposal. id is the idempotency key that makes a retry after a reconnect safe (§4.3).
The client is somewhere else now.
It travels on the same socket as the commands, which is the whole of the ordering argument:
a command proposed from a page is preceded by the navigation that produced that page, so
the Session the server hands validate is the one the client’s own copy of validate
saw. Nothing had to be added to the command frame to make that true.