code output
This commit is contained in:
parent
52fcab1d67
commit
a3814e6de0
1 changed files with 10 additions and 1 deletions
11
index.js
11
index.js
|
@ -31,7 +31,16 @@ io.on('connection', (socket) => {
|
||||||
functions = {}
|
functions = {}
|
||||||
|
|
||||||
for (const eachFuntion of parsed) {
|
for (const eachFuntion of parsed) {
|
||||||
functions[eachFuntion] = (...args) => socket.emit(BRIDGE_PREFIX + eachFuntion, ...args)
|
functions[eachFuntion] = (...args) => {
|
||||||
|
socket.emit(BRIDGE_PREFIX + eachFuntion, ...args)
|
||||||
|
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
socket.once(`functionOutput:${eachFuntion}`, (message, parseJSON) => {
|
||||||
|
if (parseJSON) resolve(JSON.parse(message))
|
||||||
|
else resolve(message)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
proxy = new Proxy(functions, handler)
|
proxy = new Proxy(functions, handler)
|
||||||
|
|
Loading…
Reference in a new issue