Advertisement
osmarks

Govos RDS

Feb 24th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local key = settings.get "govos.key"
  2. if not key then error "GovOS RDS key not found." end
  3. local ws, err = http.websocket("wss://osmarks.tk/wsthing/GovOS/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())
  16.     end
  17. end
  18.  
  19. function send(msg)
  20.     local ok = pcall(ws.send, msg)
  21.  
  22.     if not ok then
  23.         print "Disconnected"
  24.         connect()
  25.         send(msg)
  26.     end
  27. end
  28.  
  29. function writeWS()
  30.     local hist = {}
  31.     while true do
  32.         write "|> "
  33.         local input = read(nil, hist)
  34.         table.insert(hist, input)
  35.         send(input)
  36.     end
  37. end
  38.  
  39. parallel.waitForAll(writeWS, readWS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement