Skip to content

Understanding AtmosphereResourceSession

Lance edited this page Jan 22, 2014 · 3 revisions

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;
}

Step by Step Tutorials

Concepts & Architecture

15 Minutes Tutorial

Advanced Topics

API

Known WebServer Issues

References

External Documentations

githalytics.com alpha

Clone this wiki locally