File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
src/main/java/cmf/commitField/global/websocket Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 4
4
import cmf .commitField .global .exception .CustomException ;
5
5
import lombok .extern .slf4j .Slf4j ;
6
6
import org .springframework .stereotype .Component ;
7
- import org .springframework .web .socket .CloseStatus ;
8
- import org .springframework .web .socket .WebSocketHandler ;
9
- import org .springframework .web .socket .WebSocketMessage ;
10
- import org .springframework .web .socket .WebSocketSession ;
7
+ import org .springframework .web .socket .*;
11
8
12
9
import java .io .IOException ;
13
10
import java .util .*;
@@ -104,4 +101,13 @@ private Long extractRoomId(WebSocketSession session) {
104
101
}
105
102
return roomId ;
106
103
}
104
+ //메세지 전송
105
+ public void sendMessage (String payload ) throws Exception {
106
+ for (List <WebSocketSession > sessions : chatRooms .values ()) {
107
+ for (WebSocketSession session : sessions ) {
108
+ TextMessage msg = new TextMessage (payload );
109
+ session .sendMessage (msg );
110
+ }
111
+ }
112
+ }
107
113
}
You can’t perform that action at this time.
0 commit comments