From ca5bf65e9d3b933f56de9c03f0cb8004e56fef58 Mon Sep 17 00:00:00 2001 From: Tangent Wantwight Date: Tue, 12 May 2020 23:00:06 -0400 Subject: [PATCH] Change message type enum to serde-friendly strings; remove unused Ping message --- src/net/LockstepClient.ts | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/net/LockstepClient.ts b/src/net/LockstepClient.ts index 61c5afa..296935e 100644 --- a/src/net/LockstepClient.ts +++ b/src/net/LockstepClient.ts @@ -10,27 +10,22 @@ export const enum MessageTypes { /** * Reserved, likely for transient messages that wouldn't make sense appearing in a replay */ - META = 0, + META = "m", /** * 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, + SET_STATE = "s", /** * 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, + INPUT = "i", /** * 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 + GET_STATE = "g", } export type Packet = { t: TypeId } & Payload; @@ -39,14 +34,12 @@ export type ClientMessage = | Packet }> | Packet | Packet - | Packet ; export type ServerMessage = | Packet }> | Packet | Packet - | Packet ; export type Server = Callbag, ServerMessage>;