package com.gyee.wisdom.dataadapter.websocket.listener;

import com.gyee.wisdom.dataadapter.websocket.session.StompSessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.messaging.SessionUnsubscribeEvent;

@Component
public class SessionUnsubscribeEventListener implements
        ApplicationListener<SessionUnsubscribeEvent> {

//    @Autowired
//    private StompSessionService stompSessionService;

    @Override
    public void onApplicationEvent(SessionUnsubscribeEvent event) {
        System.out.println("SessionUnsubscribeEvent  rised!");
        System.out.println("message: " + event.getMessage());

//        StompHeaderAccessor accessor = StompHeaderAccessor.wrap(event.getMessage());
//        String sessionId = accessor.getSessionId();
//        String topic = accessor.getDestination();
//        stompSessionService.unSubscribeTopic(sessionId, topic);

    }

}