Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- json = require "json"
- local ws, err = http.websocket("ws://localhost:8080")
- if err then
- print(err)
- elseif ws then
- print("> CONNECTED")
- while true do
- local message = ws.receive()
- print(message)
- local obj = json.decode(message)
- if obj.type == "eval" then
- local func = load(obj['function'])
- local result = func()
- ws.send(json.encode(result))
- print("> EVAL "..tostring(result))
- end
- end
- ws.close()
- end
Add Comment
Please, Sign In to add comment