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.SessionSubscribeEvent;

@Component
public class SessionSubscribeEventListener implements
        ApplicationListener<SessionSubscribeEvent> {

//    @Autowired
//    private StompSessionService stompSessionService;

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

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

}