diff --git a/src/Net/LockstepClient.ts b/src/Net/LockstepClient.ts index 002f2db..ad22e97 100644 --- a/src/Net/LockstepClient.ts +++ b/src/Net/LockstepClient.ts @@ -7,10 +7,29 @@ import pipe from "callbag-pipe"; import { INPUT_FREQUENCY, LockstepProcessor, LockstepState } from "../Ecs/Lockstep"; export const enum MessageTypes { + /** + * Reserved, likely for transient messages that wouldn't make sense appearing in a replay + */ META = 0, + /** + * From server: initialize client state / load new level, plus informing client of their "controller number" + * From client: (op only) force a new game state, likely loading a level + */ SET_STATE = 1, + /** + * From server: array of canonical inputs for a frame + * From client: input for their controller for the next frame (TBD: strategy for handling late inputs) + */ INPUT = 2, + /** + * From server: issue request for the current game state, with a cookie to identify the response + * From client: serialized game state, with the cookie of the request + */ GET_STATE = 3, + /** + * For liveness checks / latency estimate. Echos a cookie. + * May be refactored into one of the above messages. + */ PING = 4 } @@ -18,11 +37,17 @@ export type Packet = { t: TypeId } & Payload; export type ClientMessage = | Packet }> - | Packet; + | Packet + | Packet + | Packet +; export type ServerMessage = | Packet }> - | Packet; + | Packet + | Packet + | Packet +; export type Server = Callbag, ServerMessage>;