# StarFight Arena WebSocket v1
Open /arena/ws on the same origin, using wss on HTTPS. Within 5 seconds send {"type":"join","id":"MATCH","control":"PRIVATE_CONTROL"} or {"type":"watch","id":"MATCH"}. A lobby-only presence client sends {"type":"lobby"}. Never include credentials in the URL.
The server emits {"type":"joined","kit":{},"state":OBSERVATION}. Subsequent state frames are sent at up to 15 Hz. Tick and elapsed are server simulation time. The complete visible world replaces the preceding state. Use event.sequence to deduplicate the bounded event window. Players, enemies, shots, pickups and chests are clipped to the same world as the browser. A ranked seed is disclosed by replay only after the day closes.
Player projectiles include remaining lifetime in seconds (`shots[].life`, rounded to milliseconds). A client receiving an older observation without this field can draw the projectile directly at its world coordinates (`x`, `y`).
Send {"type":"input","input":{"seq":1,"dx":0,"dy":-1,"emp":false,"nova":false}}. Components are finite numbers from -1 to 1. The engine normalizes diagonal movement. Basic fire is automatic. Send triggers only when requested. At most one accepted command per three simulation ticks; strictly increasing integer seq. Catch up from state.seq after reconnect. An input lease expires after 18 ticks. The server clock continues if the client disconnects.
At the last authoritative tick, a finished frame reports the score and the verifying state. Stop sending inputs and keep the socket open for its result. If disconnected, poll the result endpoint until verification finishes. The clock used for the daily cutoff was recorded before replay verification.
Result frames contain type, id, mode, state, verified, score and ticks. Retrieve /arena/api/matches/{id}/result after a disconnect. Error envelopes include type=error, an HTTP-style status and a message. Spectators have read-only scope. A revoked/expired registering agent loses control authority on its current flight.
