amber.server.application
Class ReceiveThread

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--amber.server.application.ReceiveThread
All Implemented Interfaces:
java.lang.Runnable, java.io.Serializable

public class ReceiveThread
extends java.lang.Thread
implements java.io.Serializable

This is the primary reception Thread. Listens at a socket, assembling packets and transmitting them to the correct handlers to process them.

Version:
1.0.0
Author:
Mark Howard, Dr. David J. Knowles
See Also:
ApplicationHandler, Serialized Form

Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ReceiveThread(java.lang.ThreadGroup group, java.net.Socket socket, ApplicationInterface parent, EventThread eventHandler)
          Construct the thread, with it's parent class so it may pass back messages.
 
Method Summary
 void deactivate()
          This function causes the flag to be set disabling this thread.
 ApplicationInterface getParent()
          This function returns the parent application to which messages will be sent.
protected  void init(java.net.Socket socket)
          Initialises the socket system for this thread.
 boolean isActive()
          Returns whether the thread is active.
 boolean isOperating()
          Returns the state of the thread.
 void restart(java.net.Socket socket)
          Forces the thread to restart using the new socket.
 void run()
          Main operating function.
 void setParent(ApplicationInterface parent)
          This function sets the parent application to which messages will be sent.
 void terminate()
          This function causes the flag to be set terminating this thread.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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

ReceiveThread

public ReceiveThread(java.lang.ThreadGroup group,
                     java.net.Socket socket,
                     ApplicationInterface parent,
                     EventThread eventHandler)
Construct the thread, with it's parent class so it may pass back messages.
Parameters:
group - ThreadGroup this thread belongs to.
socket - Socket which is the connection to the remote client.
parent - ApplicationInterface which is the parent of this thread.
eventHandler - EventThread which processes the event packets received.
Method Detail

restart

public void restart(java.net.Socket socket)
Forces the thread to restart using the new socket.

init

protected void init(java.net.Socket socket)
Initialises the socket system for this thread.
Parameters:
socket - Socket used to send the data to.

run

public void run()
Main operating function.
Overrides:
run in class java.lang.Thread

terminate

public void terminate()
This function causes the flag to be set terminating this thread.

deactivate

public void deactivate()
This function causes the flag to be set disabling this thread. The thread is still alive however it will perform no more operations.

isOperating

public boolean isOperating()
Returns the state of the thread.
Returns:
boolean true if operating normally.

isActive

public boolean isActive()
Returns whether the thread is active. This thread will be active if operating normally and inactive if suspended waiting for a connection to reestablish itself if lost.
Returns:
boolean true if active.

setParent

public void setParent(ApplicationInterface parent)
This function sets the parent application to which messages will be sent.
Parameters:
parent - ApplicationInterface which is to be the new parent.

getParent

public ApplicationInterface getParent()
This function returns the parent application to which messages will be sent.
Returns:
ApplicationInterface which is the parent.


Copyright © 2002 Clearfield Research Ltd. All Rights Reserved.