diff --git a/Geek-Stuff.md b/Geek-Stuff.md index b50f6b5..8520d4a 100644 --- a/Geek-Stuff.md +++ b/Geek-Stuff.md @@ -1,3 +1,44 @@ +# Message Format + +Vail uses [WebSockets](https://en.wikipedia.org/wiki/WebSocket) at https://vail.woozle.org/chat?repeater=Foo. It accepts two subprotocols: both of these provide the same message information, in different encodings. + +The server will accept packets in either format, but will only send packets in the format described by the subprotocol. + +## Subprotocol `binary.vail.woozle.org` + +Network byte order, "binary" version of a Message structure. + +```go +// Message is a single Vail message. +type Message struct { + // Timestamp of this message. Milliseconds since epoch. + Timestamp int64 + + // Number of connected clients. + Clients uint16 + + // Message timing in milliseconds. + // Timings alternate between tone and silence. + // For example, `A` could be sent as [80, 80, 240] + Duration []uint16 +} +``` + +## Subprotocol `json.vail.woozle.org` + +A JSON encoded version of the message structure. + +Example: + +```json +{ + "Timestamp": 1654548878301, + "Clients": 3, + "Duration": [101, 100, 103, 98, 97, 106, 315] +} +``` + + # How Vail Gets Realtime Morse Code across the Internet The Internet isn't exactly like radio waves: it still goes at near the speed of light, but there are multiple hops between endpoints, which buffer up transmissions, and multiplex them onto a single uplink connection. These repeaters (routers) are also allowed to just drop things if they need to. It's the responsibility of the communicating parties to work out whether something needs to be retransmitted. Because of this, there's no telling how long it will take for a transmission to get to a destination.