@Override public void onApplicationEvent(SessionDisconnectEvent event) { ActivityDTO activityDTO = new ActivityDTO(); activityDTO.setSessionId(event.getSessionId()); activityDTO.setPage("logout"); messagingTemplate.convertAndSend("/topic/tracker", activityDTO); }
@SubscribeMapping("/topic/activity") @SendTo("/topic/tracker") public ActivityDTO sendActivity( @Payload ActivityDTO activityDTO, StompHeaderAccessor stompHeaderAccessor, Principal principal) { activityDTO.setUserLogin(SecurityUtils.getCurrentLogin()); activityDTO.setUserLogin(principal.getName()); activityDTO.setSessionId(stompHeaderAccessor.getSessionId()); activityDTO.setIpAddress(stompHeaderAccessor.getSessionAttributes().get(IP_ADDRESS).toString()); activityDTO.setTime(dateTimeFormatter.print(Calendar.getInstance().getTimeInMillis())); log.debug("Sending user tracking data {}", activityDTO); return activityDTO; }