feud.clientserver
Class SimpleServer.ClientProcessor

java.lang.Object
  extended byfeud.clientserver.SimpleServer.ClientProcessor
All Implemented Interfaces:
java.lang.Runnable
Enclosing class:
SimpleServer

private class SimpleServer.ClientProcessor
extends java.lang.Object
implements java.lang.Runnable

This is the worker thread. Each client connecting will cause an instance of this to be spawned. Each client's thread terminates if the client logs or times out. Time out time is three seconds.


Field Summary
private  ClientInfo ci
           
private  boolean exit
           
private  java.util.List hasToSend
           
private  java.io.InputStream is
           
private  java.io.OutputStream os
           
private  java.net.Socket sock
           
 
Constructor Summary
SimpleServer.ClientProcessor(java.net.Socket sock, ClientInfo ci)
          Creates a instance with the given socket and the ClientInfo that identifies this client.
 
Method Summary
 void hasToSend(DataContainer dc)
          Used to enqueue a DataContainer into this client's broadcast queue.
 void kill()
          Stops a client's thread and removes the client from the server's clients list.
private  void processMessage(int msgType, java.util.List res)
          Processes an internal server message.
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

is

private java.io.InputStream is

os

private java.io.OutputStream os

ci

private ClientInfo ci

sock

private java.net.Socket sock

exit

private boolean exit

hasToSend

private java.util.List hasToSend
Constructor Detail

SimpleServer.ClientProcessor

public SimpleServer.ClientProcessor(java.net.Socket sock,
                                    ClientInfo ci)
                             throws java.lang.Exception
Creates a instance with the given socket and the ClientInfo that identifies this client.

Parameters:
sock - the socket to which is client is connected
ci - the ClientInfo
Throws:
java.lang.Exception - if anything goes wrong...
Method Detail

kill

public void kill()
Stops a client's thread and removes the client from the server's clients list.


hasToSend

public void hasToSend(DataContainer dc)
Used to enqueue a DataContainer into this client's broadcast queue.

Parameters:
dc - the container

run

public void run()
Specified by:
run in interface java.lang.Runnable

processMessage

private void processMessage(int msgType,
                            java.util.List res)
Processes an internal server message. Currently, this can be either log out...or log out...:-)

Parameters:
msgType - int
res - List