milestones
This commit is contained in:
+27
-4
@@ -18,7 +18,7 @@ export const useTunneldStore = defineStore('tunneldStore', {
|
||||
tunneldControl(command: TunneldCommands, udid: string = '') {
|
||||
const socketStore = useSocketStore();
|
||||
const debugLog = socketStore.debugLog;
|
||||
let fnctRtn: { sts: string; msg?: string | undefined } = { sts: '', msg: '' };
|
||||
let functionReturn: { status: string; message?: string | undefined } = { status: '', message: '' };
|
||||
if (debugLog) {
|
||||
console.log('tunneldStore: got command: ', command);
|
||||
}
|
||||
@@ -30,14 +30,37 @@ export const useTunneldStore = defineStore('tunneldStore', {
|
||||
'tunneld_control', args, (response) => {
|
||||
console.log(response.command_status, response.command);
|
||||
if (response.command_status == 'ERROR') {
|
||||
fnctRtn = { sts: 'error', msg: response.message?.toString() };
|
||||
functionReturn = { status: 'error', message: response.message?.toString() };
|
||||
throw new Error(response.message);
|
||||
} else {
|
||||
fnctRtn = { sts: 'OK', msg: response.message?.toString() };
|
||||
functionReturn = { status: 'OK', message: response.message?.toString() };
|
||||
}
|
||||
},
|
||||
);
|
||||
return fnctRtn;
|
||||
return functionReturn;
|
||||
},
|
||||
async tunneldControlAsync(command: TunneldCommands, udid: string = ''): Promise<{ status: string; message: string }> {
|
||||
const socketStore = useSocketStore();
|
||||
const debugLog = socketStore.debugLog;
|
||||
if (debugLog) {
|
||||
console.log('tunneldStore: got command: ', command);
|
||||
}
|
||||
let args: { command: TunneldCommands; udid?: string } = { command: command };
|
||||
if (udid !== '') {
|
||||
args = { command: command, udid: udid };
|
||||
}
|
||||
|
||||
return await new Promise((resolve) => {
|
||||
socket.emit('tunneld_control', args, (response) => {
|
||||
if (debugLog) {
|
||||
console.log(response.command_status, response.command);
|
||||
}
|
||||
resolve({
|
||||
status: response.command_status === 'ERROR' ? 'error' : 'OK',
|
||||
message: response.message || '',
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user