Understanding AtmosphereResourceSession - Atmosphere/atmosphere GitHub Wiki
You can use an AtmosphereResourceSession
to store serverside attributes against an AtmosphereResource
. The AtmosphereResourceSession
lives from the time it is created until the client disconnects. AtmosphereResourceSession
instances are managed by the AtmosphereResourceSessionFactory
.
eg:
public void setSessionValue(AtmosphereResource resource, String name, Object value) {
AtmosphereResourceSessionFactory factory = AtmosphereResourceSessionFactory.getDefault();
AtmosphereResourceSession session = factory.getSession(resource);
session.setAttribute(name, value);
}
public <T> T getSessionValue(AtmosphereResource resource, String name, Class<T> type) {
AtmosphereResourceSessionFactory factory = AtmosphereResourceSessionFactory.getDefault();
AtmosphereResourceSession session = factory.getSession(resource, false);
T value = null;
if (session != null) {
value = session.getAttribute(name, type);
}
return value;
}