Advertisement
craftyoyo

websocket CC

May 23rd, 2022
573
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.71 KB | None | 0 0
  1. --Lua code
  2. --using https://tweaked.cc/module/http.html#ty:Websocket:receive
  3.  
  4. print("Startup!")
  5.  
  6. local ws,err = http.websocket("ws://90.119.191.234:3738")
  7. print("Tried connecting.")
  8.  
  9. if not ws then
  10.     print("Error: ")
  11.     printError(err)
  12.     print("")
  13. end
  14.  
  15. if ws then
  16.     ws.send("Hades requesting {nf31o2jheqioefh9}")
  17.     print("Connected")
  18.    
  19.     while true do
  20.         local response = ws.receive(1)
  21.         print(response)
  22.         if not response == nil then
  23.             splitstring = response.split(response, ' ')
  24.             print("splitstring:")
  25.             print(splitstring)
  26.             shell.run(splitsring[1], splitstring[2])
  27.             break
  28.         end
  29.     end
  30.    
  31.     ws.close()
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement