// Path: rest/src/main/java/io/github/pivopil/rest/constants/WS_API.java
// public class WS_API {
//     private WS_API() {
// 
//     }
// 
//     public static final String HANDSHAKE = "/messages";
//     public static final String INSTANT_MESSAGE = "/im";
//     public static final String ACTIVE_USERS = "/users";
//     public static final String QUEUE_MESSAGES = "/queue/messages";
// 
//     public static final String QUEUE_DESTINATION_PREFIX = "/queue/";
//     public static final String TOPIC_DESTINATION_PREFIX = "/topic/";
//     public static final String APP_PREFIX = "/app";
//     public static final String TOPIC_FRIENDS_SIGNIN = "/topic/friends/signin";
//     public static final String TOPIC_FRIENDS_SIGNOUT = "/topic/friends/signout";
// }
// 
// Path: share/src/main/java/io/github/pivopil/share/entities/ActiveWebSocketUser.java
// @Entity
// public class ActiveWebSocketUser {
//     @Id
//     private String id;
// 
//     private String username;
// 
//     private Calendar connectionTime;
// 
//     public ActiveWebSocketUser() {
//     }
// 
//     public ActiveWebSocketUser(String id, String username, Calendar connectionTime) {
//         super();
//         this.id = id;
//         this.username = username;
//         this.connectionTime = connectionTime;
//     }
// 
//     public String getUsername() {
//         return this.username;
//     }
// 
//     public void setUsername(String username) {
//         this.username = username;
//     }
// 
//     public Calendar getConnectionTime() {
//         return this.connectionTime;
//     }
// 
//     public void setConnectionTime(Calendar connectionTime) {
//         this.connectionTime = connectionTime;
//     }
// 
// }
// 
// Path: share/src/main/java/io/github/pivopil/share/persistence/ActiveWebSocketUserRepository.java
// @Repository
// public interface ActiveWebSocketUserRepository
//         extends CrudRepository<ActiveWebSocketUser, String> {
// 
//     @Query("select DISTINCT(u.username) from ActiveWebSocketUser u where u.username != :username")
//     List<String> findAllActiveUsers(@Param("username") String username);
// }


import io.github.pivopil.rest.constants.WS_API;
import io.github.pivopil.share.entities.ActiveWebSocketUser;
import io.github.pivopil.share.persistence.ActiveWebSocketUserRepository;
import org.springframework.context.ApplicationListener;
import org.springframework.messaging.simp.SimpMessageSendingOperations;
import org.springframework.web.socket.messaging.SessionDisconnectEvent;
import java.util.Arrays;
import java.util.Collections;
package io.github.pivopil.rest.handlers;



public class WebSocketDisconnectHandler<S>
        implements ApplicationListener<SessionDisconnectEvent> {
    private ActiveWebSocketUserRepository repository;
    private SimpMessageSendingOperations messagingTemplate;

    public WebSocketDisconnectHandler(SimpMessageSendingOperations messagingTemplate,
// Path: rest/src/main/java/io/github/pivopil/rest/constants/WS_API.java
// public class WS_API {
//     private WS_API() {
// 
//     }
// 
//     public static final String HANDSHAKE = "/messages";
//     public static final String INSTANT_MESSAGE = "/im";
//     public static final String ACTIVE_USERS = "/users";
//     public static final String QUEUE_MESSAGES = "/queue/messages";
// 
//     public static final String QUEUE_DESTINATION_PREFIX = "/queue/";
//     public static final String TOPIC_DESTINATION_PREFIX = "/topic/";
//     public static final String APP_PREFIX = "/app";
//     public static final String TOPIC_FRIENDS_SIGNIN = "/topic/friends/signin";
//     public static final String TOPIC_FRIENDS_SIGNOUT = "/topic/friends/signout";
// }
// 
// Path: share/src/main/java/io/github/pivopil/share/entities/ActiveWebSocketUser.java
// @Entity
// public class ActiveWebSocketUser {
//     @Id
//     private String id;
// 
//     private String username;
// 
//     private Calendar connectionTime;
// 
//     public ActiveWebSocketUser() {
//     }
// 
//     public ActiveWebSocketUser(String id, String username, Calendar connectionTime) {
//         super();
//         this.id = id;
//         this.username = username;
//         this.connectionTime = connectionTime;
//     }
// 
//     public String getUsername() {
//         return this.username;
//     }
// 
//     public void setUsername(String username) {
//         this.username = username;
//     }
// 
//     public Calendar getConnectionTime() {
//         return this.connectionTime;
//     }
// 
//     public void setConnectionTime(Calendar connectionTime) {
//         this.connectionTime = connectionTime;
//     }
// 
// }
// 
// Path: share/src/main/java/io/github/pivopil/share/persistence/ActiveWebSocketUserRepository.java
// @Repository
// public interface ActiveWebSocketUserRepository
//         extends CrudRepository<ActiveWebSocketUser, String> {
// 
//     @Query("select DISTINCT(u.username) from ActiveWebSocketUser u where u.username != :username")
//     List<String> findAllActiveUsers(@Param("username") String username);
// }


// Path: rest/src/main/java/io/github/pivopil/rest/handlers/WebSocketDisconnectHandler.java
import io.github.pivopil.rest.constants.WS_API;
import io.github.pivopil.share.entities.ActiveWebSocketUser;
import io.github.pivopil.share.persistence.ActiveWebSocketUserRepository;
import org.springframework.context.ApplicationListener;
import org.springframework.messaging.simp.SimpMessageSendingOperations;
import org.springframework.web.socket.messaging.SessionDisconnectEvent;
import java.util.Arrays;
import java.util.Collections;

package io.github.pivopil.rest.handlers;



public class WebSocketDisconnectHandler<S>
        implements ApplicationListener<SessionDisconnectEvent> {
    private ActiveWebSocketUserRepository repository;
    private SimpMessageSendingOperations messagingTemplate;

    public WebSocketDisconnectHandler(SimpMessageSendingOperations messagingTemplate,
                                      ActiveWebSocketUserRepository repository) {