Skip to content

Commit

Permalink
Fix for #1063
Browse files Browse the repository at this point in the history
  • Loading branch information
jfarcand committed May 2, 2013
1 parent e6a6e6a commit 5ad5b37
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ public interface AtmosphereResourceEvent {
*/
public AtmosphereResource getResource();

/**
* Return true if the client closed the connection and send the Atmosphere close message. You must
* use the {@link org.atmosphere.interceptor.OnDisconnectInterceptor} in order to receive the proper value,
* and enableProtocol set to true on the client side (enabledProtocol is true by default).
* @return
*/
public boolean isClosedByClient();

/**
* Write the {@link Object} using the {@link OutputStream} by invoking
* the current {@link Serializer}. If {@link Serializer} is null, the {@link Object}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public class AtmosphereResourceEventImpl implements AtmosphereResourceEvent {
// The current message
protected Object message;
protected AtmosphereResourceImpl resource;
private final AtomicBoolean isClosedByClient = new AtomicBoolean(false);

public AtmosphereResourceEventImpl(AtmosphereResourceImpl resource) {
this.resource = resource;
Expand All @@ -94,6 +95,18 @@ public AtmosphereResourceEventImpl(AtmosphereResourceImpl resource, boolean isCa
this.throwable = throwable;
}

public AtmosphereResourceEventImpl(AtmosphereResourceImpl resource,
boolean isCancelled,
boolean isResumedOnTimeout,
boolean isClosedByClient,
Throwable throwable) {
this.isCancelled.set(isCancelled);
this.isResumedOnTimeout.set(isResumedOnTimeout);
this.resource = resource;
this.throwable = throwable;
this.isClosedByClient.set(isClosedByClient);
}

/**
* {@inheritDoc}
*/
Expand All @@ -108,6 +121,13 @@ public boolean isSuspended() {
return resource == null ? false : resource.action().type() == Action.TYPE.SUSPEND;
}

/**
* {@inheritDoc}
*/
public boolean isClosedByClient() {
return isClosedByClient.get();
}

/**
* Return the object that were pass to {@link Broadcaster#broadcast(java.lang.Object)}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public Action inspect(final AtmosphereResource r) {
logger.debug("AtmosphereResource {} disconnected", uuid);
AtmosphereResource ss = AtmosphereResourceFactory.getDefault().find(uuid);
if (ss != null) {
ss.notifyListeners(new AtmosphereResourceEventImpl(AtmosphereResourceImpl.class.cast(r), true, false));
ss.notifyListeners(new AtmosphereResourceEventImpl(AtmosphereResourceImpl.class.cast(r), false, false, true, null));
try {
try {
// https://github.com/Atmosphere/atmosphere/issues/983
Expand Down

0 comments on commit 5ad5b37

Please sign in to comment.