Commit 1e8c5c7106b00637a409fbd0627c4e2236474103

Authored by Notmoo-PC\Notmoo
1 parent efad9683

Modification émission requêtes texte : utilisation format json + modification ad…

…resse ip broadcast : 230.0.0.1 -> 10.255.255.255
src/main/java/servlet/CalibrationServlet.java
@@ -65,11 +65,11 @@ public class CalibrationServlet extends HttpServlet{ @@ -65,11 +65,11 @@ public class CalibrationServlet extends HttpServlet{
65 65
66 byte[] buf = new byte[256]; 66 byte[] buf = new byte[256];
67 67
68 - String dString = "CALIB=" + clientMacAddress + ";SERV=" + Inet4Address.getLocalHost().getHostAddress()+";LOC_ID="+locationId+";"; 68 + String dString = "{\"CALIB\": \"" + clientMacAddress + "\", \"SERV\": \"" + Inet4Address.getLocalHost().getHostAddress()+"\", \"LOC_ID\": \""+locationId+"\"}";
69 buf = dString.getBytes(); 69 buf = dString.getBytes();
70 70
71 // send it 71 // send it
72 - InetAddress group = InetAddress.getByName("230.0.0.1"); 72 + InetAddress group = InetAddress.getByName("10.255.255.255");
73 DatagramPacket packet = new DatagramPacket(buf, buf.length, group, 4446); 73 DatagramPacket packet = new DatagramPacket(buf, buf.length, group, 4446);
74 socket.send(packet); 74 socket.send(packet);
75 } catch (IOException e) { 75 } catch (IOException e) {
src/main/java/servlet/MapScaleServlet.java
@@ -21,8 +21,8 @@ public class MapScaleServlet extends HttpServlet { @@ -21,8 +21,8 @@ public class MapScaleServlet extends HttpServlet {
21 int mapId = Integer.parseInt(servletRequest.getParameter("MAP_ID")); 21 int mapId = Integer.parseInt(servletRequest.getParameter("MAP_ID"));
22 Map map = mapService.getMap(mapId); 22 Map map = mapService.getMap(mapId);
23 23
24 - servletResponse.setContentType("text/plain");  
25 - servletResponse.getWriter().print(String.format("{x1:%f;y1:%f;x2:%f;y2:%f}", map.getX_topLeft() 24 + servletResponse.setContentType("application/json");
  25 + servletResponse.getWriter().print(String.format("{\"x1\":\"%f\",\"y1\":\"%f\",\"x2\":\"%f\",\"y2\":\"%f\"}", map.getX_topLeft()
26 , map.getY_topLeft(), map.getX_bottomRight(), map.getY_bottomRight())); 26 , map.getY_topLeft(), map.getX_bottomRight(), map.getY_bottomRight()));
27 } 27 }
28 28
src/main/java/servlet/PositioningServlet.java
@@ -41,8 +41,8 @@ public class PositioningServlet extends HttpServlet{ @@ -41,8 +41,8 @@ public class PositioningServlet extends HttpServlet{
41 loc = posServ.getLocation(clientMacAddr); 41 loc = posServ.getLocation(clientMacAddr);
42 }while(loc==null); 42 }while(loc==null);
43 43
44 - servletResponse.setContentType("text/plain");  
45 - servletResponse.getWriter().print(String.format("{x:%f;y:%f;map:%d}", loc.getX(), loc.getY(), loc.getMap().getId())); 44 + servletResponse.setContentType("application/json");
  45 + servletResponse.getWriter().print(String.format("{\"x\": \"%f\", \"y\": \"%f\", \"map\": \"%d\"}", loc.getX(), loc.getY(), loc.getMap().getId()));
46 } 46 }
47 47
48 @Override 48 @Override
@@ -62,11 +62,11 @@ public class PositioningServlet extends HttpServlet{ @@ -62,11 +62,11 @@ public class PositioningServlet extends HttpServlet{
62 62
63 byte[] buf = new byte[256]; 63 byte[] buf = new byte[256];
64 64
65 - String dString = "LOCATE=" + clientMacAddress + ";SERV=" + Inet4Address.getLocalHost().getHostAddress()+";"; 65 + String dString = "{\"LOCATE\": \"" + clientMacAddress + "\", \"SERV\": \"" + Inet4Address.getLocalHost().getHostAddress()+"\"}";
66 buf = dString.getBytes(); 66 buf = dString.getBytes();
67 67
68 // send it 68 // send it
69 - InetAddress group = InetAddress.getByName("230.0.0.1"); 69 + InetAddress group = InetAddress.getByName("10.255.255.255");
70 DatagramPacket packet = new DatagramPacket(buf, buf.length, group, 4446); 70 DatagramPacket packet = new DatagramPacket(buf, buf.length, group, 4446);
71 socket.send(packet); 71 socket.send(packet);
72 } catch (IOException e) { 72 } catch (IOException e) {