|
@@ -7,6 +7,7 @@ package rsx;
|
|
|
|
|
|
import java.net.InetAddress;
|
|
|
import java.util.ArrayList;
|
|
|
+import org.json.JSONObject;
|
|
|
import rsx.tcp.TcpClient;
|
|
|
import rsx.udp.Broadcast;
|
|
|
|
|
@@ -52,12 +53,29 @@ public class BomberStudentClient {
|
|
|
return this.socket.connect();
|
|
|
}
|
|
|
|
|
|
- public boolean send(String method, String ressource, String param){
|
|
|
- return false;
|
|
|
+ public boolean send(String method, String ressource, JSONObject param){
|
|
|
+ //Verif que la methode existe
|
|
|
+ method = method.toUpperCase();
|
|
|
+ if(!method.equals("POST") && !method.equals("GET")){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //Creation json pour envoi
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("methode", method);
|
|
|
+ json.put("ressource", ressource);
|
|
|
+ json.put("param", param);
|
|
|
+ //Envoi
|
|
|
+ this.socket.send(json.toString());
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
public BomberStudentReponse receive(){
|
|
|
- return null;
|
|
|
+ String msg = this.socket.receive();
|
|
|
+ if(msg == null){
|
|
|
+ return new BomberStudentReponse();
|
|
|
+ } else {
|
|
|
+ return new BomberStudentReponse(msg);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public boolean close(){
|