Advertisement
JohnDog3112

websockets

Mar 31st, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. local handle, err = http.websocket("ws://99.3.41.97:8080")
  2. function receive()
  3. while true do
  4. print(handle.receive())
  5. end
  6. end
  7. function send()
  8. while true do
  9. handle.send(read())
  10. end
  11. end
  12. function ping()
  13. while true do
  14. sleep(10)
  15. handle.send("ping")
  16. end
  17. end
  18. if not handle then
  19. printError(err)
  20. else
  21. parallel.waitForAny(receive, send, ping)
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement