code output

This commit is contained in:
Chayapak 2023-07-23 09:10:01 +07:00
parent 52fcab1d67
commit a3814e6de0

View file

@ -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)