package org.matrix.socket;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @author huangxiahao
 */
public class SocketPool {

    private static final ConcurrentHashMap<Long, ClientSocket> ONLINE_SOCKET_MAP = new ConcurrentHashMap<>();


    public static void add(ClientSocket clientSocket){
        if (clientSocket != null && clientSocket.getKey()!=null) {
            ONLINE_SOCKET_MAP.put(clientSocket.getKey(), clientSocket);
        }
    }

    public static void remove(Long key){
        if (key!=null) {
            ONLINE_SOCKET_MAP.remove(key);
        }
    }

    public static ClientSocket get(Long key){
       return ONLINE_SOCKET_MAP.get(key);
    }
}