Procházet zdrojové kódy

un petit chat en websocket

master
DemiSel před 3 roky
rodič
revize
658c6fa0a0

+ 26
- 0
src/main/java/websockets/CuisineWebSocketChichatHandler.java Zobrazit soubor

@@ -0,0 +1,26 @@
1
+package websockets;
2
+
3
+import io.undertow.websockets.core.AbstractReceiveListener;
4
+import io.undertow.websockets.core.BufferedTextMessage;
5
+import io.undertow.websockets.core.WebSocketChannel;
6
+import io.undertow.websockets.core.WebSockets;
7
+
8
+import java.util.ArrayList;
9
+
10
+public class CuisineWebSocketChichatHandler extends AbstractReceiveListener {
11
+
12
+    final int MAX_MESSAGES = 5;
13
+    ArrayList<String> vMessageHistory;
14
+
15
+    protected CuisineWebSocketChichatHandler() {
16
+
17
+    }
18
+
19
+    protected void onFullTextMessage(WebSocketChannel iChannel, BufferedTextMessage iTextMessage) {
20
+        String vMessageContent = iTextMessage.getData();
21
+        System.out.println("Received " + iTextMessage.toString());
22
+        //Handle message on webSocket
23
+        WebSockets.sendText(vMessageContent, iChannel, null);
24
+    }
25
+
26
+}

+ 10
- 0
src/main/resources/components/chat.html Zobrazit soubor

@@ -0,0 +1,10 @@
1
+<!DOCTYPE html>
2
+<html lang="en">
3
+<head>
4
+  <meta charset="UTF-8">
5
+  <title>$Title$</title>
6
+</head>
7
+<body>
8
+$END$
9
+</body>
10
+</html>

+ 0
- 0
src/main/resources/components/chatscript.js Zobrazit soubor


Načítá se…
Zrušit
Uložit