js call native over ws completed

This commit is contained in:
王劲鹏
2019-10-24 10:39:06 +08:00
committed by pengfei.zhou
parent 9864b57b21
commit 086beeb2c2
2 changed files with 28 additions and 4 deletions

View File

@@ -30,10 +30,11 @@ wss.on('connection', function connection(ws) {
case "injectGlobalJSFunction":
console.log(messageObject.name)
Reflect.set(global, messageObject.name, function() {
let args = [].slice.call(arguments)
ws.send(JSON.stringify({
cmd: 'injectGlobalJSFunction',
name: messageObject.name,
arguments: arguments
arguments: args
}))
})
break