vooga.engine.networking.server
Class Handler

java.lang.Object
  extended by java.lang.Thread
      extended by vooga.engine.networking.server.Handler
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
ChatHandler, ClientHandler

public abstract class Handler
extends java.lang.Thread

Class that handles communicating over the network. Handler extends Thread and has a socket to send and receive chats through as well as a session ID to group Handlers that are part of the same game session. Subclasses will need to override the run method to put the code that sends and receives messages using the socket.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  int sessionID
           
protected  GameSocket socket
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Handler(GameSocket socket, int sessionID)
          Initializes a Handler with a socket to communicate through and a gameNumber that represents the handler's game session's id.
 
Method Summary
 int getSessionID()
           
 GameSocket getSocket()
           
abstract  void run()
          Called once the thread is started.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

socket

protected GameSocket socket

sessionID

protected int sessionID
Constructor Detail

Handler

public Handler(GameSocket socket,
               int sessionID)
Initializes a Handler with a socket to communicate through and a gameNumber that represents the handler's game session's id.

Method Detail

run

public abstract void run()
Called once the thread is started. Here is the place to put any code for sending and receiving messages to and from the socket.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

getSessionID

public int getSessionID()
Returns:
the id of this handler's game session.

getSocket

public GameSocket getSocket()
Returns:
the GameSocket that this handler is communicating through.