org.atmosphere.samples.tictactoe
Class TTTHandler
java.lang.Object
org.atmosphere.samples.tictactoe.TTTHandler
- All Implemented Interfaces:
- AtmosphereHandler
public class TTTHandler
- extends java.lang.Object
- implements AtmosphereHandler
Simple handler that listens for GET and POST requests, and responds appropriately.
Uses long polling, with a GET that listens for new data, and a POST that triggers
broadcasts to all clients, resuming the GETs and returning that data.
Actual game logic is held in a separate class - TTTGame.
- Author:
- driscoll
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TTTHandler
public TTTHandler()
onRequest
public void onRequest(AtmosphereResource event)
throws java.io.IOException
- On GET, suspend the conneciton. On POST, update game logic, send
broadcast, and resume the connection.
- Specified by:
onRequest in interface AtmosphereHandler
- Parameters:
event -
- Throws:
java.io.IOException
onStateChange
public void onStateChange(AtmosphereResourceEvent event)
throws java.io.IOException
- Resume the underlying response on the first Broadcast
- Specified by:
onStateChange in interface AtmosphereHandler
- Parameters:
event -
- Throws:
java.io.IOException
destroy
public void destroy()
- Specified by:
destroy in interface AtmosphereHandler
Copyright © 2012. All Rights Reserved.