//package com.kospo.talk.config.ws;
//
//import org.springframework.context.annotation.Configuration;
//import org.springframework.web.socket.CloseStatus;
//import org.springframework.web.socket.WebSocketHandler;
//import org.springframework.web.socket.WebSocketSession;
//import org.springframework.web.socket.handler.TextWebSocketHandler;
//import org.springframework.web.socket.handler.WebSocketHandlerDecorator;
//import org.springframework.web.socket.handler.WebSocketHandlerDecoratorFactory;
//
//import java.io.IOException;
//import java.util.Map;
//import java.util.concurrent.ConcurrentHashMap;
//@Configuration
//public class CustomWebSocketHandler implements WebSocketHandlerDecoratorFactory {
//    private final Map<String, WebSocketSession> sessions = new ConcurrentHashMap<>();
//
//    @Override
//    public WebSocketHandler decorate(WebSocketHandler handler) {
//        return new WebSocketHandlerDecorator(handler) {
//            @Override
//            public void afterConnectionEstablished(WebSocketSession session) throws Exception {
//                String sessionId = session.getId();
//                sessions.put(sessionId, session);
//
//                super.afterConnectionEstablished(session);
//            }
//
//            @Override
//            public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception {
//                String sessionId = session.getId();
//                try {
//                    session.close(status);
//                } catch(IOException e) {
//
//                } finally {
//                    sessions.remove(sessionId);
//                }
//                super.afterConnectionClosed(session, status);
//            }
//        };
//    }
//
//}
