io.baltoro.remote.WSSessionPool Maven / Gradle / Ivy
package io.baltoro.remote;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentLinkedDeque;
import javax.websocket.Session;
public class WSSessionPool
{
private static Map sessionMap = new HashMap(500);
private ConcurrentLinkedDeque sessionQueue;
private WSSessionPool()
{
sessionQueue = new ConcurrentLinkedDeque<>();
}
static WSSessionPool get(String instanceUuid)
{
WSSessionPool pool = sessionMap.get(instanceUuid);
if(pool == null)
{
pool = new WSSessionPool();
sessionMap.put(instanceUuid, pool);
}
return pool;
}
void addSession(Session session)
{
sessionQueue.add(session);
}
Session getSession()
{
return sessionQueue.poll();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy