|
@@ -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
|
+}
|