1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package net.brabenetz.app.springstompserver.testtools;
21
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
24 import org.springframework.lang.Nullable;
25 import org.springframework.messaging.simp.stomp.StompCommand;
26 import org.springframework.messaging.simp.stomp.StompHeaders;
27 import org.springframework.messaging.simp.stomp.StompSession;
28 import org.springframework.messaging.simp.stomp.StompSessionHandlerAdapter;
29
30 public class WebSocketStompSessionHandler extends StompSessionHandlerAdapter {
31
32 private static final Logger LOG = LoggerFactory.getLogger(WebSocketStompSessionHandler.class);
33
34 private String name;
35
36 public WebSocketStompSessionHandler(String name) {
37 this.name = name;
38 }
39
40 @Override
41 public void afterConnected(StompSession stompSession, StompHeaders connectedHeaders) {
42 LOG.info(name + " afterConnected: " + stompSession.getSessionId());
43 }
44
45 @Override
46 public void handleFrame(StompHeaders headers, Object payload) {
47 LOG.info(name + " StompSessionHandler got new Payload: " + payload);
48 }
49
50 @Override
51 public void handleException(StompSession stompSession, @Nullable StompCommand command,
52 StompHeaders headers, byte[] payload, Throwable e) {
53 LOG.error(name + " handleException {}", e.getMessage(), e);
54 }
55
56 @Override
57 public void handleTransportError(StompSession stompSession, Throwable e) {
58 LOG.error(name + " handleTransportError {}", e.getMessage(), e);
59 }
60
61
62 }