All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.hison.api.caching.CachingWebSocketSessionManager Maven / Gradle / Ivy

Go to download

API-Link is a novel solution for Spring projects, aimed at streamlining development by eliminating the need for individual controllers. It allows developers to use a single 'cmd' value to invoke service layer methods, simplifying workflow and boosting productivity.

The newest version!
package io.github.hison.api.caching;

import org.springframework.web.socket.WebSocketSession;
import java.util.concurrent.CopyOnWriteArrayList;

/** 
 * @author Hani son
 * @version 1.0.0
 */
public class CachingWebSocketSessionManager {
    private static CachingWebSocketSessionManager instance;
    private final CopyOnWriteArrayList sessions = new CopyOnWriteArrayList<>();

    private final CachingHandler handler;
    private CachingWebSocketSessionManager() {
        this.handler = CachingHandlerFactory.getHandler();
    }

    public static synchronized CachingWebSocketSessionManager getInstance() {
        if (instance == null) {
            instance = new CachingWebSocketSessionManager();
        }
        return instance;
    }

    public void addSession(WebSocketSession session) {
        handler.addSession(sessions, session);
    }
    
    public void removeSession(WebSocketSession session) {
        handler.removeSession(sessions, session);
    }

    public void notifyAllSessions(String message) {
        handler.notifyAllSessions(sessions, message);
    }

    public String getEndPoint() {
        return handler.getEndPoint();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy