org.atmosphere.samples.tictactoe
Class TTTHandler

java.lang.Object
  extended by 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

Constructor Summary
TTTHandler()
           
 
Method Summary
 void destroy()
           
 void onRequest(AtmosphereResource event)
          On GET, suspend the conneciton.
 void onStateChange(AtmosphereResourceEvent event)
          Resume the underlying response on the first Broadcast
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TTTHandler

public TTTHandler()
Method Detail

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.