|
1 | | -package com.goorm.team9.icontact.config.websocket; |
2 | | - |
3 | | -import com.goorm.team9.icontact.domain.chat.service.WebSocketSessionService; |
4 | | -import org.springframework.stereotype.Component; |
5 | | -import org.springframework.web.socket.CloseStatus; |
6 | | -import org.springframework.web.socket.WebSocketSession; |
7 | | -import org.springframework.web.socket.handler.TextWebSocketHandler; |
8 | | - |
9 | | -@Component |
10 | | -public class WebSocketHandler extends TextWebSocketHandler { |
11 | | - |
12 | | - private final WebSocketSessionService webSocketSessionService; |
13 | | - |
14 | | - public WebSocketHandler(WebSocketSessionService webSocketSessionService) { |
15 | | - this.webSocketSessionService = webSocketSessionService; |
16 | | - } |
17 | | - |
18 | | - @Override |
19 | | - public void afterConnectionEstablished(WebSocketSession session) throws Exception { |
20 | | - Long roomId = (Long) session.getAttributes().get("roomId"); |
21 | | - Long clientId = (Long) session.getAttributes().get("clientId"); |
22 | | - String senderNickname = (String) session.getAttributes().get("senderNickname"); |
23 | | - webSocketSessionService.addSession(roomId, clientId, senderNickname, session); |
24 | | - } |
25 | | - |
26 | | - @Override |
27 | | - public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception { |
28 | | - Long roomId = (Long) session.getAttributes().get("roomId"); |
29 | | - String senderNickname = (String) session.getAttributes().get("senderNickname"); |
30 | | - webSocketSessionService.removeSession(roomId, senderNickname); |
31 | | - } |
32 | | - |
33 | | -} |
34 | | - |
| 1 | +//package com.goorm.team9.icontact.config.websocket; |
| 2 | +// |
| 3 | +//import com.goorm.team9.icontact.domain.chat.service.WebSocketSessionService; |
| 4 | +//import org.springframework.stereotype.Component; |
| 5 | +//import org.springframework.web.socket.CloseStatus; |
| 6 | +//import org.springframework.web.socket.WebSocketSession; |
| 7 | +//import org.springframework.web.socket.handler.TextWebSocketHandler; |
| 8 | +// |
| 9 | +//@Component |
| 10 | +//public class WebSocketHandler extends TextWebSocketHandler { |
| 11 | +// |
| 12 | +// private final WebSocketSessionService webSocketSessionService; |
| 13 | +// |
| 14 | +// public WebSocketHandler(WebSocketSessionService webSocketSessionService) { |
| 15 | +// this.webSocketSessionService = webSocketSessionService; |
| 16 | +// } |
| 17 | +// |
| 18 | +// @Override |
| 19 | +// public void afterConnectionEstablished(WebSocketSession session) throws Exception { |
| 20 | +// Long roomId = (Long) session.getAttributes().get("roomId"); |
| 21 | +// Long clientId = (Long) session.getAttributes().get("clientId"); |
| 22 | +// String senderNickname = (String) session.getAttributes().get("senderNickname"); |
| 23 | +// webSocketSessionService.addSession(roomId, clientId, senderNickname, session); |
| 24 | +// } |
| 25 | +// |
| 26 | +// @Override |
| 27 | +// public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception { |
| 28 | +// Long roomId = (Long) session.getAttributes().get("roomId"); |
| 29 | +// String senderNickname = (String) session.getAttributes().get("senderNickname"); |
| 30 | +// webSocketSessionService.removeSession(roomId, senderNickname); |
| 31 | +// } |
| 32 | +// |
| 33 | +//} |
| 34 | +// |
0 commit comments