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

io.baltoro.remote.WSSessionPool Maven / Gradle / Ivy

There is a newer version: 4.0.12
Show newest version
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