From 3066b6ac7436f510d2402a15a643c87bd84d75ac Mon Sep 17 00:00:00 2001 From: metamuffin Date: Fri, 10 Jun 2022 18:51:00 +0200 Subject: update protocol spec --- karld/protocol.d.ts | 45 +++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 30 deletions(-) (limited to 'karld/protocol.d.ts') 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 = 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 -} - +export type ServerboundPacket = Sync | Handshake | ListTasks | ListInstances | UpdateTask | RemoveTask +export type ClientboundPacket = Handshake | Error | TaskList | InstanceList | Sync + +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, -- cgit v1.2.3-70-g09d2