Skip to content

Commit

Permalink
refactor StompConnectionListener.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladik-gif committed Oct 30, 2024
1 parent 01739b8 commit d54a6dd
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ public class StompConnectionListener {

@EventListener
public void handleWebSocketConnectListener(SessionConnectEvent event) {
String email = getUserEmailFromEvent(event);
contactOnlineService.setUserOnline(email);
log.info("Contact [{}] is connected", email);
contactOnlineService.setUserOnline(getUserEmailFromEvent(event));
log.info("Contact [{}] is connected", getUserEmailFromEvent(event));
}

@EventListener
public void handleWebSocketDisconnectListener(SessionDisconnectEvent event) {
String email = getUserEmailFromEvent(event);
contactOnlineService.setUserOffline(email);
log.info("Contact [{}] is disconnected", email);
contactOnlineService.setUserOffline(getUserEmailFromEvent(event));
log.info("Contact [{}] is disconnected", getUserEmailFromEvent(event));
}

private String getUserEmailFromEvent(AbstractSubProtocolEvent event) {
Expand Down

0 comments on commit d54a6dd

Please sign in to comment.