Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import processing.net.*;
  2.  
  3. Client client;
  4.  
  5.  
  6. String keyboardInput = "";
  7.  
  8. void setup()
  9. {
  10. size(300, 300);
  11. client = new Client(this, "10.11.4.92", 5204);
  12. }
  13.  
  14. void draw()
  15. {
  16. background(255);
  17. if (client != null)
  18. {
  19. if (client.readString() != null)
  20. {
  21. String incomingMessage = client.readString();
  22. incomingMessage = incomingMessage.trim();
  23. println("server : " + incomingMessage);
  24. }
  25. }
  26. }
  27.  
  28.  
  29. void keyPressed()
  30. {
  31. if (key != '\n')
  32. keyboardInput += key;
  33. else
  34. {
  35. println("client : " + keyboardInput);
  36. client.write(keyboardInput);
  37. keyboardInput = "";
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement