com.eriksilkensen.net
Class IncomingReader

java.lang.Object
  extended by com.eriksilkensen.net.IncomingReader
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
SudokuReader

public class IncomingReader
extends java.lang.Object
implements java.lang.Runnable

An important component in the Server/Client relationship thats main role is to handle messages sent between Clients.

This class isn't abstract, but it still probably shouldn't be used on its own. All that it does when a message comes in is first echo it back to standard output, and then notify any of the Client's Observers of a change and pushes them a null argument.

The handleMessage() method is defined specifically for subclasses to get a chance at hooking into the actual reading process of a message and to act upon it. Its void return type prevents them from modifying the message in place - so if something more is needed they will have to override the entire run() method. The IncomingReader's instance data are left protected though, to be as accomdating as possible.

Since:
1.0.2
Version:
03/02/07
Author:
Erik Silkensen

Field Summary
protected  java.lang.Object arg
           
protected  Client client
           
 
Constructor Summary
IncomingReader(Client client, java.lang.String name)
          Constructor, connects the Client reference
 
Method Summary
 java.lang.String getName()
          Returns the actual name of the person using this IncomingReader to any class that is not inside the com.eriksilkensen.net package or is not extending this IncomingReader.
 void handleMessage(java.lang.String message)
          Optional hook method for taking some sort of action depending on what the message is.
 void run()
          Executed when this Reader is created as a job for a Thread
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

client

protected Client client

arg

protected java.lang.Object arg
Constructor Detail

IncomingReader

public IncomingReader(Client client,
                      java.lang.String name)
Constructor, connects the Client reference

Parameters:
client - the Client reference
name - the name of the person using this Reader
Method Detail

run

public void run()
Executed when this Reader is created as a job for a Thread

Specified by:
run in interface java.lang.Runnable

handleMessage

public void handleMessage(java.lang.String message)
Optional hook method for taking some sort of action depending on what the message is. Included here to play nicely with subclasses that might want to add additional functionality.

Parameters:
message - the message

getName

public java.lang.String getName()
Returns the actual name of the person using this IncomingReader to any class that is not inside the com.eriksilkensen.net package or is not extending this IncomingReader.