Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local key = settings.get "lasers.key"
- if not key then error "SPUDNET key for laser control not found." end
- local ws, err = http.websocket("wss://osmarks.tk/wsthing/lasers/admin", {
- authorization = "Key " .. key
- })
- if err then
- error(err)
- else
- print "Connected"
- end
- function readWS()
- while true do
- local txt = ws.receive()
- print(txt)
- end
- end
- function send(msg)
- local ok = ws.send(msg)
- end
- function writeWS()
- local hist = {}
- while true do
- write "|> "
- local input = read(nil, hist)
- table.insert(hist, input)
- send(input)
- sleep(0.1)
- end
- end
- local function terminateHandler()
- coroutine.yield "terminate"
- pcall(ws.close)
- end
- parallel.waitForAll(writeWS, readWS, terminateHandler)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement