Guest User

Untitled

a guest
Apr 24th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. require 'socket'
  2.  
  3. SERVER = "143.60.60.29"
  4. PORT = "12345"
  5.  
  6. $app = Shoes.app do
  7. # => background(gradient('#CFF', '#FFF'))
  8. @output = stack(:heigth => 600, :width => 450, :margin => 10)
  9.  
  10. def display text
  11. @output.append do
  12. para text
  13. end
  14. end
  15.  
  16. box = edit_box
  17. button "Send" do
  18. $chat.send(box.text, 0, SERVER, PORT)
  19. end
  20.  
  21. end
  22.  
  23. $chat = UDPSocket.new
  24. $chat.bind("0.0.0.0", PORT)
  25.  
  26. Thread.new do
  27.  
  28. $chat.send("HELO", 0, SERVER, PORT)
  29.  
  30. while !nil
  31. input, sender = $chat.recvfrom(255)
  32.  
  33. if /PIN/.match(input)
  34. $chat.send("HI", 0, SERVER, PORT)
  35. else
  36. $app.display(input)
  37. end
  38. end
  39. end
Add Comment
Please, Sign In to add comment