ServerTest.java 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package test;
  2. import java.net.UnknownHostException;
  3. import java.util.ArrayList;
  4. import org.json.JSONObject;
  5. import rsx.BomberStudentClient;
  6. import rsx.BomberStudentRequest;
  7. import rsx.tcp.TcpClient;
  8. /**
  9. * Exemple appel vers le serveur
  10. * @author Arthur Brandao
  11. */
  12. public class ServerTest {
  13. /**
  14. * @param args the command line arguments
  15. */
  16. public static void main(String[] args) throws InterruptedException {
  17. /*
  18. Broadcast b = new Broadcast(18426);
  19. System.out.println(b.search("i'm a bomberstudent server"));
  20. System.out.println("Resultat : " + !b.getServers().isEmpty());
  21. //*/
  22. /*
  23. TcpClient cli = new TcpClient("127.0.0.1", 18642);
  24. cli.connect();
  25. cli.send("Bonjour toi le serveur comment que ça va ?");
  26. System.out.println(cli.receive());
  27. cli.close();
  28. //*/
  29. //*
  30. BomberStudentClient bsc = new BomberStudentClient();
  31. int a = bsc.findServer();
  32. if(a == 0){
  33. System.err.println("Aucun serveur");
  34. return;
  35. }
  36. bsc.addHandler("test", new ServerHandlerTest());
  37. bsc.selectServer(0);
  38. bsc.send("POST", "aze/rty");
  39. System.out.println("A");
  40. Thread.sleep(15000);
  41. System.out.println("B");
  42. JSONObject json = bsc.receive();
  43. System.out.println(json.toString(1));
  44. bsc.close();
  45. //*/
  46. }
  47. }