Browse Source

mic-mac d'adresse ip corrigé

master
DemiSel 3 years ago
parent
commit
30bd3ca904
1 changed files with 29 additions and 23 deletions
  1. 29
    23
      src/main/java/CuisineHTTPServer.java

+ 29
- 23
src/main/java/CuisineHTTPServer.java View File

@@ -20,9 +20,13 @@ import static io.undertow.Handlers.*;
20 20
 public class CuisineHTTPServer extends Thread
21 21
 {
22 22
     final int webPagePort = 8080;
23
+
23 24
     final int webSocketPort = 42069;
25
+    final String webSocketHost = "192.168.0.24";
26
+
24 27
     final int tcpSocketPort = 6868;
25
-    final String HOST = "localhost" ;
28
+    final String HOST = "0.0.0.0" ;
29
+
26 30
 
27 31
     private static CuisineTCPServer fCuisineTCPServer;
28 32
 
@@ -39,7 +43,7 @@ public class CuisineHTTPServer extends Thread
39 43
         Undertow WebPageServer = Undertow.builder()
40 44
                 .addHttpListener(webPagePort, HOST)
41 45
                 .setHandler(
42
-                        new CuisineResponseHandler("ws://"+HOST+":"+webSocketPort+"/data")
46
+                        new CuisineResponseHandler("ws://"+webSocketHost+":"+webSocketPort+"/data")
43 47
                             ).build();
44 48
         WebPageServer.start();
45 49
 
@@ -131,30 +135,32 @@ public class CuisineHTTPServer extends Thread
131 135
         StringBuilder vBuilder = new StringBuilder();
132 136
         vBuilder
133 137
             .append("<head>")
134
-            .append("<meta charset=\"UTF-8\">")
135
-            .append("<style>")
138
+            .append("   <meta charset=\"UTF-8\">")
139
+            .append("   <style>")
136 140
             .append(sHtml_CSS)
137
-            .append("</style>")
141
+            .append("   </style>")
138 142
             .append("</head>")
139
-            .append("<div class=\"pre\">")
143
+            .append("<body>")
144
+            .append("   <div class=\"pre\">")
140 145
             .append(sHtml_ASCII_title)
141
-            .append("</div>")
142
-            .append("<h1 id=\"tempValue\">None</h1>")
143
-            .append("<script>")
144
-            .append("var socket=new WebSocket(\""+iWsUri+"\");\n")
145
-            .append("let connected=false;")
146
-            .append("let view=document.getElementById(\"tempValue\");")
147
-            .append("socket.onerror=function(error){connected=false;view.innerHTML=\"oups :(\";};")
148
-            .append("socket.onmessage=function(event){view.innerHTML=event.data+\"&deg;C\"};")
149
-            .append("socket.onopen=function(e){")
150
-            .append("connected=true;")
151
-            .append("callServer();")
152
-            .append("};")
153
-            .append("var callServer=function(){")
154
-            .append("socket.send(\"coucou\");")
155
-            .append("};")
156
-            .append("let timer=setInterval(callServer,100);")
157
-            .append("</script>")
146
+            .append("   </div>")
147
+            .append("   <h1 id=\"tempValue\">None</h1>")
148
+            .append("   <script>")
149
+            .append("       var socket=new WebSocket(\""+iWsUri+"\");\n")
150
+            .append("       let connected=false;")
151
+            .append("       let view=document.getElementById(\"tempValue\");")
152
+            .append("       socket.onerror=function(error){connected=false;view.innerHTML=\"oups :(\";};")
153
+            .append("       socket.onmessage=function(event){view.innerHTML=event.data+\"&deg;C\"};")
154
+            .append("       socket.onopen=function(e){")
155
+            .append("           connected=true;")
156
+            .append("           callServer();")
157
+            .append("       };")
158
+            .append("       var callServer=function(){")
159
+            .append("           socket.send(\"coucou\");")
160
+            .append("       };")
161
+            .append("       let timer=setInterval(callServer,100);")
162
+            .append("   </script>")
163
+            .append("</body>")
158 164
             .append("")
159 165
 
160 166
             ;

Loading…
Cancel
Save