Created
May 31, 2010 19:50
-
-
Save jfarcand/420199 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AsyncServlet implements AtmosphereHandler<HttpServletRequest, HttpServletResponse> { | |
@Override | |
public void onRequest(AtmosphereResource<HttpServletRequest,HttpServletResponse> resource) | |
throws ServletException, IOException { | |
try { | |
System.out.println("Starting onRequest"); | |
resource.suspend(); | |
// Will be executed using a ScheduledThreadPool (can also use scheduleBroadcast) | |
resource.delayBroadcast("Something",10, TimeUnit.SECONDS); | |
} finally { | |
} | |
} | |
@Override | |
public void onStateChange(AtmosphereResourceEvent<HttpServletRequest,HttpServletResponse> event) { | |
if (!event.isResuming() && !event.isCancelled()) { | |
event.resume(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment