|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.eriksilkensen.net.IncomingReader
public class IncomingReader
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.
| 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 |
|---|
protected Client client
protected java.lang.Object arg
| Constructor Detail |
|---|
public IncomingReader(Client client,
java.lang.String name)
client - the Client referencename - the name of the person using this Reader| Method Detail |
|---|
public void run()
run in interface java.lang.Runnablepublic void handleMessage(java.lang.String message)
message - the messagepublic java.lang.String getName()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||