diff options
Diffstat (limited to 'app/client/socket/socket.system.js')
| -rw-r--r-- | app/client/socket/socket.system.js | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/app/client/socket/socket.system.js b/app/client/socket/socket.system.js index 5279d21..3d80902 100644 --- a/app/client/socket/socket.system.js +++ b/app/client/socket/socket.system.js @@ -1,6 +1,5 @@ import { dispatch } from '../store' import types from '../types' -import uuidv1 from 'uuid/v1' import { socket } from './socket.connection' socket.on('system_res', (data) => { @@ -33,31 +32,3 @@ socket.on('system_res', (data) => { } }) -export function run_system_command(opt) { - return syscall_async('run_system_command', opt) -} -export function list_directory(opt) { - return syscall_async('list_directory', opt).then(res => res.files) -} -export function run_script(opt) { - return syscall_async('run_script', opt) -} -export const syscall_async = (tag, payload, ttl=10000) => { - return new Promise( (resolve, reject) => { - const uuid = uuidv1() - const timeout = setTimeout(() => { - socket.off('system_res', cb) - reject('timeout') - }, ttl) - const cb = (data) => { - if (!data.uuid) return - if (data.uuid === uuid) { - clearTimeout(timeout) - socket.off('system_res', cb) - resolve(data) - } - } - socket.emit('system', { cmd: tag, payload, uuid }) - socket.on('system_res', cb) - }) -} |
