diff --git a/index.js b/index.js index 9988598..0808592 100644 --- a/index.js +++ b/index.js @@ -31,7 +31,16 @@ io.on('connection', (socket) => { functions = {} 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)