|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.atmosphere.cpr.AtmosphereSession
public class AtmosphereSession
An AtmosphereSession allow an application to keep track of the AtmosphereResource associated with a remote client.
For example, with the long-polling transport, a new AtmosphereResource will be created every time a
reconnect occurs. If an application has a reference to the AtmosphereResource, the object will become
out of scope, or unusable, after the reconnection. To fix this problem, you can use this class to track and invoke
tryAcquire() ()} or acquire()} in order to get the AtmosphereResource.
Broadcaster, e.g you must make sure the AtmosphereResource
has called Broadcaster.addAtmosphereResource(AtmosphereResource) once if you want this class to work.
| Field Summary | |
|---|---|
protected BroadcasterListenerAdapter |
broadcasterListener
|
protected Semaphore |
latch
|
protected com.vaadin.external.org.slf4j.Logger |
logger
|
protected Broadcaster[] |
relatedBroadcasters
|
protected AtomicReference<AtmosphereResource> |
resource
|
protected boolean |
usesLongPolling
|
protected String |
uuid
|
| Constructor Summary | |
|---|---|
AtmosphereSession(AtmosphereResource resource)
Track the current AtmosphereResource with all created Broadcaster |
|
AtmosphereSession(AtmosphereResource r,
Broadcaster... broadcasters)
|
|
| Method Summary | |
|---|---|
AtmosphereResource |
acquire()
Retrieve the AtmosphereResource associated with this session. |
void |
close()
|
AtmosphereResource |
tryAcquire()
Retrieve the AtmosphereResource associated with this session. |
AtmosphereResource |
tryAcquire(int timeInSecond)
Retrieve the AtmosphereResource associated with this session. |
String |
uuid()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final com.vaadin.external.org.slf4j.Logger logger
protected final AtomicReference<AtmosphereResource> resource
protected String uuid
protected final Semaphore latch
protected BroadcasterListenerAdapter broadcasterListener
protected Broadcaster[] relatedBroadcasters
protected final boolean usesLongPolling
| Constructor Detail |
|---|
public AtmosphereSession(AtmosphereResource r,
Broadcaster... broadcasters)
public AtmosphereSession(AtmosphereResource resource)
AtmosphereResource with all created Broadcaster
resource - an AtmosphereResource| Method Detail |
|---|
public AtmosphereResource acquire()
AtmosphereResource associated with this session. If there is no AtmosphereResource
associated, return null.
AtmosphereResource
public AtmosphereResource tryAcquire()
throws InterruptedException
AtmosphereResource associated with this session. If there is no AtmosphereResource
associated, wait until the AtmosphereResource is retrieved. This method will wait 60 seconds and then return.
AtmosphereResource
InterruptedException
public AtmosphereResource tryAcquire(int timeInSecond)
throws InterruptedException
AtmosphereResource associated with this session. If there is no AtmosphereResource
associated, wait until the AtmosphereResource is retrieved.
If the resource uses long polling as its transport, this method treats the resource as a single use connection
and will make subsequent callers wait until the client reconnects and the broadcasterListener's
BroadcasterListenerAdapter.onAddAtmosphereResource(org.atmosphere.cpr.Broadcaster, org.atmosphere.cpr.AtmosphereResource) method gets called again.
WARNING: Use this method with long polling only if you intend to broadcast to the returned resource. If no broadcast is made, the client won't have to reconnect, the resource won't get re-added, and any subsequent calls will have to wait until the timeout is reached.
timeInSecond - The timeToWait before continuing the execution
AtmosphereResource or null if the resource was not set and it didn't get set during the timeout
InterruptedExceptionpublic void close()
public String uuid()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||