diff options
-rw-r--r-- | karlcommon/src/protocol.rs | 2 | ||||
-rw-r--r-- | karld/protocol.d.ts | 41 |
2 files changed, 14 insertions, 29 deletions
diff --git a/karlcommon/src/protocol.rs b/karlcommon/src/protocol.rs index a86ca3d..f971ef2 100644 --- a/karlcommon/src/protocol.rs +++ b/karlcommon/src/protocol.rs @@ -13,7 +13,7 @@ pub enum ClientboundPacket { } #[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(tag = "type", content = "data", rename_all = "snake_case")] +#[serde(tag = "kind", content = "details", rename_all = "snake_case")] pub enum ProtoError { UnknownTask, FormatError(String), diff --git a/karld/protocol.d.ts b/karld/protocol.d.ts index a592146..be1a9bd 100644 --- a/karld/protocol.d.ts +++ b/karld/protocol.d.ts @@ -1,34 +1,19 @@ -// { type: "handshake", version: "10"} -// { type: "handshake", data: {version: "10"}} -//! { "handshake": {version: "10"}} +export type ServerboundPacket = Sync | Handshake | ListTasks | ListInstances | UpdateTask | RemoveTask +export type ClientboundPacket = Handshake | Error | TaskList | InstanceList | Sync -export type ServerboundPacket = Download | UpdateTask | RemoveTask -export type ClientboundPacket = Handshake | DownloadResponse - -interface Handshake { - type: "handshake" - data: { version: string } -} - -interface Download { - type: "download", - data: null -} -interface DownloadResponse { - type: "download_response", - data: { tasks: Task[] } -} - -interface UpdateTask { - type: "update_task", - data: Task -} -interface RemoveTask { - type: "remove_task", - data: Task -} +interface Sync { type: "sync", data: null } +interface Error { type: "error", data: { kind: "unknown_task", details: null } | { kind: "format_error", details: string } } +interface Handshake { type: "handshake", data: { version: string } } +interface ListTasks { type: "list_tasks", data: null } +interface TaskList { type: "task_list", data: Task[] } +interface ListInstances { type: "list_instances", data: null } +interface InstanceList { type: "instance_list", data: Instance[] } +interface UpdateTask { type: "update_task", data: Task } +interface RemoveTask { type: "remove_task", data: number } +interface Instance { of: number, at: Range } +interface Range { start?: number, end?: number } interface Task { id: number name: string, |