net.sourceforge.jsrvany.test
Class ChatServerThread

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--net.sourceforge.jsrvany.test.ChatServerThread

public class ChatServerThread
extends java.lang.Thread
implements BusListener

This class is a single thread started by ChatServer

Copyright (c) 1999 Damian Fauth

 


Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ChatServerThread(java.net.Socket sock, Bus bus)
          Constructor assigning socket
 
Method Summary
 void communicate()
          implement the comms
 java.lang.String getHandle()
          get the handle of this listener
 java.util.Date getLastWriteDate()
          get the date-time of last write
 java.util.Date getRegisterDate()
          get the date-time of registration
 void notify(java.lang.String data)
          the bus has notified the listener of new bus data
 void run()
          run this thread
protected  void stopRunning()
          signal thread to stop running
protected  void write(java.lang.String message)
          write to the client
 
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

ChatServerThread

public ChatServerThread(java.net.Socket sock,
                        Bus bus)
Constructor assigning socket
Parameters:
sock - is the Socket object
Method Detail

run

public void run()
run this thread
Overrides:
run in class java.lang.Thread

communicate

public void communicate()
                 throws java.io.IOException
implement the comms
Returns:
void
Throws:
java.io.IOException - may be thrown if there are network connectivity problems

notify

public void notify(java.lang.String data)
the bus has notified the listener of new bus data
Specified by:
notify in interface BusListener
Parameters:
data - is the data as a String
Returns:
void

getHandle

public java.lang.String getHandle()
get the handle of this listener
Specified by:
getHandle in interface BusListener
Returns:
String being this listeners handle

write

protected void write(java.lang.String message)
              throws java.io.IOException
write to the client
Parameters:
message - is the message to send as a String
Returns:
void
Throws:
java.io.IOException - may be thrown if there are network connectivity problems

stopRunning

protected void stopRunning()
                    throws java.io.IOException
signal thread to stop running
Returns:
void
Throws:
java.io.IOException - may be thrown if there are network connectivity problems

getRegisterDate

public java.util.Date getRegisterDate()
get the date-time of registration
Specified by:
getRegisterDate in interface BusListener
Returns:
Date being the date of registration

getLastWriteDate

public java.util.Date getLastWriteDate()
get the date-time of last write
Specified by:
getLastWriteDate in interface BusListener
Returns:
Date being the date of the last submission