SHOW:
|
|
- or go back to the newest paste.
| 1 | - | local key = settings.get "govos.key" |
| 1 | + | local key = settings.get "lasers.key" |
| 2 | - | if not key then error "GovOS RDS key not found." end |
| 2 | + | if not key then error "SPUDNET key for laser control not found." end |
| 3 | - | local ws, err = http.websocket("wss://osmarks.tk/wsthing/GovOS/admin", {
|
| 3 | + | local ws, err = http.websocket("wss://osmarks.tk/wsthing/lasers/admin", {
|
| 4 | authorization = "Key " .. key | |
| 5 | }) | |
| 6 | ||
| 7 | if err then | |
| 8 | error(err) | |
| 9 | else | |
| 10 | print "Connected" | |
| 11 | end | |
| 12 | ||
| 13 | function readWS() | |
| 14 | while true do | |
| 15 | - | print(ws.receive()) |
| 15 | + | local txt = ws.receive() |
| 16 | print(txt) | |
| 17 | end | |
| 18 | end | |
| 19 | ||
| 20 | - | local ok = pcall(ws.send, msg) |
| 20 | + | |
| 21 | local ok = ws.send(msg) | |
| 22 | - | if not ok then |
| 22 | + | |
| 23 | - | print "Disconnected" |
| 23 | + | |
| 24 | - | connect() |
| 24 | + | |
| 25 | - | send(msg) |
| 25 | + | |
| 26 | while true do | |
| 27 | write "|> " | |
| 28 | local input = read(nil, hist) | |
| 29 | table.insert(hist, input) | |
| 30 | send(input) | |
| 31 | sleep(0.1) | |
| 32 | end | |
| 33 | end | |
| 34 | ||
| 35 | local function terminateHandler() | |
| 36 | coroutine.yield "terminate" | |
| 37 | pcall(ws.close) | |
| 38 | end | |
| 39 | - | parallel.waitForAll(writeWS, readWS) |
| 39 | + | |
| 40 | parallel.waitForAll(writeWS, readWS, terminateHandler) |