commandNetworking
Class MessageListenerThread

java.lang.Object
  extended by java.lang.Thread
      extended by commandNetworking.MessageListenerThread
All Implemented Interfaces:
java.lang.Runnable

public class MessageListenerThread
extends java.lang.Thread

This thread represents a thread who's only function is to listen for messages from the server A message is received by first reading the length of the package, then reading that number of bytes from the stream Listening intervals are hardcoded at 30ms.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
MessageListenerThread(Communicator com)
          A simple constructor that assigns a communicator to the thread, index is set to zero
MessageListenerThread(Communicator com, int index)
          Another simple constructor, this also sets a given index
 
Method Summary
static Packet DeserializeObject(byte[] byteArray)
          Decode an object and return it
 void run()
          Overwrites the run method in Thread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MessageListenerThread

public MessageListenerThread(Communicator com)
A simple constructor that assigns a communicator to the thread, index is set to zero

Parameters:
com -

MessageListenerThread

public MessageListenerThread(Communicator com,
                             int index)
Another simple constructor, this also sets a given index

Parameters:
com -
index -
Method Detail

DeserializeObject

public static Packet DeserializeObject(byte[] byteArray)
Decode an object and return it

Parameters:
byteArray -
Returns:

run

public void run()
Overwrites the run method in Thread. Required to overwrite. This method is called when start() is invoked on the thread. The method mainly consists of a while loop that checks whether the boolean stop is true. If false it will read bytes from the stream and decode it into a command. Loop interval is hardcoded to 30ms.

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