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

io.nadron.service.impl.SessionRegistry Maven / Gradle / Ivy

Go to download

Nadron is a high speed socket based java game server written using Netty and Mike Rettig's Jetlang. It is specifically tuned for network based multiplayer games and supports TCP and UDP network protocols.

There is a newer version: 0.7
Show newest version
package io.nadron.service.impl;

import io.nadron.app.Session;
import io.nadron.service.SessionRegistryService;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;



public class SessionRegistry implements SessionRegistryService
{
	protected final Map sessions;
	
	public SessionRegistry()
	{
		sessions = new ConcurrentHashMap(1000);
	}
	
	@Override
	public Session getSession(T key)
	{
		return sessions.get(key);
	}

	@Override
	public boolean putSession(T key, Session session)
	{
		if(null == key ||  null == session)
		{
			return false;
		}
		
		if(null == sessions.put(key, session))
		{
			return true;
		}
		return false;
	}
	
	@Override
	public boolean removeSession(Object key)
	{
		return null != sessions.remove(key) ? true : false;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy