Crossfire JXClient, Trunk
|
Public Member Functions | |
boolean | acceptsMessages () |
void | beforeRead (Client client) |
NameReader (ChatServer chatServer) | |
void | onData (Client client, ByteBuffer buffer, int bytes) |
Private Member Functions | |
void | onUserNameRead (Client client, String name) |
void | sendRemainingParts (Client client, String[] strings) |
Private Attributes | |
final StringBuilder | buffer = new StringBuilder() |
final ChatServer | chatServer |
boolean | once = true |
Static Private Attributes | |
static final String | NEWLINE = "\n" |
The first state a newly connected
is in, this handles writing out the welcoming message and reads the response up to a newline. When a newline character have been received it changes the handler from NameReader to MessageReader on the client.
Definition at line 50 of file NameReader.java.
NameReader.NameReader | ( | ChatServer | chatServer | ) |
Definition at line 56 of file NameReader.java.
References chatServer.
boolean NameReader.acceptsMessages | ( | ) |
Implements DataReader.
Definition at line 75 of file NameReader.java.
void NameReader.beforeRead | ( | Client | client | ) |
Writes the welcoming message to the client the first time this method is called.
client | the client to receive the message |
Implements DataReader.
Definition at line 67 of file NameReader.java.
void NameReader.onData | ( | Client | client, |
ByteBuffer | buffer, | ||
int | bytes | ||
) |
Receives incoming data from the socket, searches for a newline and tries to set the username if one is found
Implements DataReader.
Definition at line 84 of file NameReader.java.
References buffer, client, name(), NEWLINE, and onUserNameRead().
|
private |
Splits the name on the newlines, takes the first as the username and appends everything else to the clients message buffer. Sets the clients handler to MessageReader.
client | the client to set the username for |
name | the string containing the buffered input |
Definition at line 101 of file NameReader.java.
References chatServer, client, name(), NEWLINE, and sendRemainingParts().
Referenced by onData().
|
private |
Appends the remaining parts to the clients message buffer
client | the client |
strings | the messages to append to the buffer |
Definition at line 115 of file NameReader.java.
References client.
Referenced by onUserNameRead().
|
private |
Definition at line 51 of file NameReader.java.
Referenced by onData().
|
private |
Definition at line 52 of file NameReader.java.
Referenced by NameReader(), and onUserNameRead().
|
staticprivate |
Definition at line 54 of file NameReader.java.
Referenced by onData(), and onUserNameRead().
|
private |
Definition at line 53 of file NameReader.java.
Referenced by beforeRead().