diff options
author | metamuffin <yvchraiqi@protonmail.com> | 2022-06-10 18:51:00 +0200 |
---|---|---|
committer | metamuffin <yvchraiqi@protonmail.com> | 2022-06-10 18:51:00 +0200 |
commit | 3066b6ac7436f510d2402a15a643c87bd84d75ac (patch) | |
tree | ee2690e42986e6caafeae30f1aec56dbe7706c4d | |
parent | 4e7b383fe2c1ccea7871c708ff1b281451feddd0 (diff) | |
download | karlender-3066b6ac7436f510d2402a15a643c87bd84d75ac.tar karlender-3066b6ac7436f510d2402a15a643c87bd84d75ac.tar.bz2 karlender-3066b6ac7436f510d2402a15a643c87bd84d75ac.tar.zst |
update protocol spec
-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, |