Advertisement
toast_account_i_made

Untitled

Mar 15th, 2025 (edited)
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. local websocketHost = "ws://localhost:8080/cdn"
  2. local socket = http.websocket(websocketHost)
  3.  
  4. local monitor = peripheral.wrap("right")
  5. monitor.clear()
  6. monitor.setCursorPos(1, 1)
  7. function netLoop()
  8. if (not socket) then
  9. monitor.write("Failed to connect");
  10. end
  11. while true do
  12. local data = {os.pullEvent()}
  13. if (data[1] == "websocket_message") then
  14. monitor.write(data[3]);
  15. end
  16. if (data[1] == "websocket_closed") then
  17. monitor.write("close " .. data[2]);
  18. end
  19. end
  20. end
  21.  
  22. parallel.waitForAll(netLoop)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement