Commit 1e8c5c7106b00637a409fbd0627c4e2236474103
1 parent
efad9683
Modification émission requêtes texte : utilisation format json + modification ad…
…resse ip broadcast : 230.0.0.1 -> 10.255.255.255
Showing
3 changed files
with
8 additions
and
8 deletions
Show diff stats
src/main/java/servlet/CalibrationServlet.java
... | ... | @@ -65,11 +65,11 @@ public class CalibrationServlet extends HttpServlet{ |
65 | 65 | |
66 | 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 | 69 | buf = dString.getBytes(); |
70 | 70 | |
71 | 71 | // send it |
72 | - InetAddress group = InetAddress.getByName("230.0.0.1"); | |
72 | + InetAddress group = InetAddress.getByName("10.255.255.255"); | |
73 | 73 | DatagramPacket packet = new DatagramPacket(buf, buf.length, group, 4446); |
74 | 74 | socket.send(packet); |
75 | 75 | } catch (IOException e) { | ... | ... |
src/main/java/servlet/MapScaleServlet.java
... | ... | @@ -21,8 +21,8 @@ public class MapScaleServlet extends HttpServlet { |
21 | 21 | int mapId = Integer.parseInt(servletRequest.getParameter("MAP_ID")); |
22 | 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 | 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 | 41 | loc = posServ.getLocation(clientMacAddr); |
42 | 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 | 48 | @Override |
... | ... | @@ -62,11 +62,11 @@ public class PositioningServlet extends HttpServlet{ |
62 | 62 | |
63 | 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 | 66 | buf = dString.getBytes(); |
67 | 67 | |
68 | 68 | // send it |
69 | - InetAddress group = InetAddress.getByName("230.0.0.1"); | |
69 | + InetAddress group = InetAddress.getByName("10.255.255.255"); | |
70 | 70 | DatagramPacket packet = new DatagramPacket(buf, buf.length, group, 4446); |
71 | 71 | socket.send(packet); |
72 | 72 | } catch (IOException e) { | ... | ... |