Your own library
This section is the protocol underneath Woosh.Wisp and @woosh-no/wisp: every frame your wisp
sends and hears, and every rule Woosh holds it to. Read it to write a library in another language,
or to see what the libraries do for you. You never need it to build a wisp in C# or TypeScript.
The shape of it
Section titled “The shape of it”- Two HTTP requests, and only two. Your wisp’s id and secret buy a short-lived token with OAuth2’s client credentials request, and pictures for cards are uploaded as files. Nothing else a wisp does goes over HTTP.
- One WebSocket, the line. The token’s answer names its address. Text frames carry JSON, one frame per line of text. It is the protocol the Woosh apps speak, with a few additions for wisps.
- Calls and answers. Everything your wisp does, and every read, is a call:
{"i":7,"t":"send", "d":{...}}, answered by{"r":7,"v":...}or a refusal with a reason in a code. Up to 32 may be on their way at once. - Numbered events. Everything your wisp hears is an event numbered in its group, such as
{"c":61,"n":120,"t":"grants","d":{...}}. Keep the last number you handled, and coming back within 10 minutes replays what you missed. - Limits told up front. The line’s
readynames your wisp’s limits, and a call past one answerslimitedwith how long to wait.
What a good library does
Section titled “What a good library does”Woosh.Wisp does each of these. A library of your own should too, and each step links to the page
that has its rules:
- Connect. Buy a token, open the line its answer names with
?delivery=seen, sendhellowithin 10 seconds, and wait forready(The line). - Send the commands in your user’s code after every
ready, whole (Commands). - Keep your place. Move the cursor past an event only once it is handled, store it, and resume
with it; when
readysays events were missed, catch up by reading (Keeping your place, Catching up). - Come back after a drop on the backoff
readynames, and act on each close code (Closes, and coming back). Follow amoveto another address without a gap (Moving). - Keep order. Up to 32 calls on their way, but one channel’s lines in the order they were written (32 in flight).
- Pace to the limits rather than bouncing off them, and keep only the newest of a burst of edits (Budgets and limits).
- Never post twice. Give every line a send id, so a retry after a drop is answered with the line it already made (Acting in a server).
- Check before sending. Hold cards and forms to their rules before they go, so a mistake is your user’s error in their own code, not a refusal later (Cards, Forms).
- Answer in time. A run or a press has 15 seconds; pass over one that comes back after it (Commands, Presses).
- Hand over. Let a second line for the same slice take over without a gap, for deploys (Hand-overs, Slices).
The pages
Section titled “The pages”| Page | Holds |
|---|---|
| Your first wisp without a library | Every request and frame, start to finish, and a whole wisp in about 70 lines of Node |
| The line | The token, hello and ready, frames, calls, keeping your place, closes, moving, hand-overs |
| What a wisp hears | Every event, by what the admin granted |
| Commands | The command list, a run, and answering it |
| Cards | Every block, its keys and limits, patches and live frames |
| Presses and private cards | Presses, menus, tallies, private cards |
| Forms | A form’s fields, a sending, and its rules |
| Acting in a server | Every call that acts, and every read |
| Budgets and limits | Every limit, how limited looks, and pacing |
| Slices and scale | Splitting a wisp across processes |
| Reference | Every frame, call, event, error code and HTTP route on one page |
Test against
Section titled “Test against”- Real frames. Every frame on these pages is one Woosh’s own tests hold it to.
- Every form rule as cases.
/forms/rules.jsonholds forms and sendings, each with the answer Woosh gives, so your library can check forms exactly as Woosh does. - A worked library.
Woosh.Wispon NuGet is MIT licensed and does every step above.