|
@@ -1,4 +1,4 @@
|
1
|
|
-package websockets;
|
|
1
|
+package websockets.handlers;
|
2
|
2
|
|
3
|
3
|
import io.undertow.websockets.core.AbstractReceiveListener;
|
4
|
4
|
import io.undertow.websockets.core.BufferedTextMessage;
|
|
@@ -7,12 +7,12 @@ import io.undertow.websockets.core.WebSockets;
|
7
|
7
|
|
8
|
8
|
import java.util.ArrayList;
|
9
|
9
|
|
10
|
|
-public class CuisineWebSocketChichatHandler extends AbstractReceiveListener {
|
|
10
|
+public class CuisineWebSocketChichatHandler extends CuisineReceiveListener {
|
11
|
11
|
|
12
|
12
|
final int MAX_MESSAGES = 10;
|
13
|
13
|
ArrayList<String> vMessageHistory;
|
14
|
14
|
|
15
|
|
- protected CuisineWebSocketChichatHandler() {
|
|
15
|
+ public CuisineWebSocketChichatHandler() {
|
16
|
16
|
vMessageHistory = new ArrayList<>();
|
17
|
17
|
}
|
18
|
18
|
|
|
@@ -29,8 +29,23 @@ public class CuisineWebSocketChichatHandler extends AbstractReceiveListener {
|
29
|
29
|
{
|
30
|
30
|
vBuilder.append(vMessage+"\n");
|
31
|
31
|
}
|
32
|
|
- //Handle message on webSocket
|
|
32
|
+
|
33
|
33
|
WebSockets.sendText(vBuilder.toString(), iChannel, null);
|
34
|
34
|
}
|
35
|
35
|
|
|
36
|
+ public void register(WebSocketChannel iChannel)
|
|
37
|
+ {
|
|
38
|
+
|
|
39
|
+ }
|
|
40
|
+
|
|
41
|
+ public void unregister(WebSocketChannel iChannel)
|
|
42
|
+ {
|
|
43
|
+
|
|
44
|
+ }
|
|
45
|
+
|
|
46
|
+ protected void notifyOthers(String iMessages)
|
|
47
|
+ {
|
|
48
|
+ Websockets.sendText(iMessages)
|
|
49
|
+ }
|
|
50
|
+
|
36
|
51
|
}
|