Advertisement
ecco7777

CC Websocket Slave

Jan 30th, 2022 (edited)
776
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.79 KB | None | 0 0
  1. if fs.exists("json")==false then
  2.     shell.run("pastebin get 4nRg9CHU json")
  3. end
  4. if fs.exists("pf")==false then
  5.     shell.run("pastebin get 2HXb06ic pf")
  6. end
  7. shell.run("rm connect")
  8. shell.run("pastebin get Xk3GT1mr connect")
  9. os.loadAPI("connect")
  10. os.loadAPI("json")
  11. os.loadAPI("pf")
  12. require("pf")
  13.  
  14. local ws,err = http.websocket("ws://"..connect.code)
  15. local id = pf.getID()
  16.  
  17. if ws then
  18.     while true do
  19.         local msg = ws.receive()
  20.         print(msg)
  21.         if msg~=nil then
  22.             if string.find(msg,"receiver\"")~=nil then
  23.                 local obj = json.decode(msg)
  24.                 if obj.receiver==id or obj.receiver=="broadcast" then
  25.                     eval(obj["func"])
  26.                     sleep(0)
  27.                 end
  28.             end
  29.         end
  30.     end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement