io.nadron.service.impl.SessionRegistry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nadron Show documentation
Show all versions of nadron Show documentation
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.
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;
}
}