implement wsh conn commands (#319)

This commit is contained in:
Mike Sawka
2024-09-03 23:04:19 -07:00
committed by GitHub
parent 9b720ef455
commit 7bc154771a
8 changed files with 213 additions and 57 deletions
+8 -2
View File
@@ -589,9 +589,9 @@ function subscribeToConnEvents() {
try {
const connStatus = event.data as ConnStatus;
if (connStatus == null || util.isBlank(connStatus.connection)) {
console.log("connchange2 early return");
return;
}
console.log("connstatus update", connStatus);
let curAtom = getConnStatusAtom(connStatus.connection);
globalStore.set(curAtom, connStatus);
} catch (e) {
@@ -603,7 +603,13 @@ function subscribeToConnEvents() {
function getConnStatusAtom(conn: string): jotai.PrimitiveAtom<ConnStatus> {
let rtn = ConnStatusMap.get(conn);
if (rtn == null) {
const connStatus: ConnStatus = { connection: conn, connected: false, error: null, status: "disconnected" };
const connStatus: ConnStatus = {
connection: conn,
connected: false,
error: null,
status: "disconnected",
hasconnected: false,
};
rtn = jotai.atom(connStatus);
ConnStatusMap.set(conn, rtn);
}
+10 -5
View File
@@ -17,6 +17,11 @@ class WshServerType {
return WOS.wshServerRpcHelper_call("authenticate", data, opts);
}
// command "connconnect" [call]
ConnConnectCommand(data: string, opts?: RpcOpts): Promise<void> {
return WOS.wshServerRpcHelper_call("connconnect", data, opts);
}
// command "conndisconnect" [call]
ConnDisconnectCommand(data: string, opts?: RpcOpts): Promise<void> {
return WOS.wshServerRpcHelper_call("conndisconnect", data, opts);
@@ -27,16 +32,16 @@ class WshServerType {
return WOS.wshServerRpcHelper_call("connensure", data, opts);
}
// command "connforceconnect" [call]
ConnForceConnectCommand(data: string, opts?: RpcOpts): Promise<void> {
return WOS.wshServerRpcHelper_call("connforceconnect", data, opts);
}
// command "connreinstallwsh" [call]
ConnReinstallWshCommand(data: string, opts?: RpcOpts): Promise<void> {
return WOS.wshServerRpcHelper_call("connreinstallwsh", data, opts);
}
// command "connstatus" [call]
ConnStatusCommand(opts?: RpcOpts): Promise<ConnStatus[]> {
return WOS.wshServerRpcHelper_call("connstatus", null, opts);
}
// command "controllerinput" [call]
ControllerInputCommand(data: CommandBlockInputData, opts?: RpcOpts): Promise<void> {
return WOS.wshServerRpcHelper_call("controllerinput", data, opts);