Esempio n. 1
0
 @Override
 public void onApplicationEvent(SessionDisconnectEvent event) {
   ActivityDTO activityDTO = new ActivityDTO();
   activityDTO.setSessionId(event.getSessionId());
   activityDTO.setPage("logout");
   messagingTemplate.convertAndSend("/topic/tracker", activityDTO);
 }
Esempio n. 2
0
 @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;
 }