Crossfire JXClient, Trunk
|
Public Member Functions | |
void | appendMessage (String message) |
Client (AsynchronousSocketChannel channel, ClientReader reader) | |
void | close () |
String | getUserName () |
String | nextMessage () |
void | read (CompletionHandler< Integer, ? super ByteBuffer > completionHandler) |
void | run () |
void | setReader (ClientReader reader) |
void | setUserName (String userName) |
void | writeMessageFrom (Client client, String message) |
void | writeStringMessage (String string) |
Private Member Functions | |
void | writeBuffer (ByteBuffer buffer) |
void | writeFromQueue () |
void | writeMessage (final ByteBuffer buffer) |
Private Attributes | |
final AsynchronousSocketChannel | channel |
final StringBuilder | messageBuffer = new StringBuilder() |
final Queue< ByteBuffer > | queue = new LinkedList<ByteBuffer>() |
AtomicReference< ClientReader > | reader |
String | userName |
boolean | writing = false |
Client represents a remote connection to the chat server. It contains methods for reading and writing messages from the channel. Messages are considered to be separated by newline, so incomplete messages are buffered in the
.
All reads and writes are asynchronous and uses the nio2 asynchronous elements.
Definition at line 59 of file Client.java.
Client.Client | ( | AsynchronousSocketChannel | channel, |
ClientReader | reader | ||
) |
Definition at line 68 of file Client.java.
void Client.appendMessage | ( | String | message | ) |
Definition at line 192 of file Client.java.
References messageBuffer.
void Client.close | ( | ) |
String Client.getUserName | ( | ) |
Definition at line 188 of file Client.java.
References userName.
String Client.nextMessage | ( | ) |
Definition at line 202 of file Client.java.
References messageBuffer.
void Client.read | ( | CompletionHandler< Integer, ? super ByteBuffer > | completionHandler | ) |
Enqueue a read
completionHandler | callback on completed read |
Definition at line 154 of file Client.java.
References channel.
void Client.run | ( | ) |
void Client.setReader | ( | ClientReader | reader | ) |
Definition at line 184 of file Client.java.
References reader.
void Client.setUserName | ( | String | userName | ) |
Definition at line 180 of file Client.java.
References userName.
|
private |
Definition at line 113 of file Client.java.
References channel, result, and writeFromQueue().
Referenced by writeFromQueue().
|
private |
Definition at line 97 of file Client.java.
References queue, writeBuffer(), and writing.
Referenced by writeBuffer(), and writeMessage().
|
private |
Enqueues a write of the buffer to the channel. The call is asynchronous so the buffer is not safe to modify after passing the buffer here.
buffer | the buffer to send to the channel |
Definition at line 80 of file Client.java.
References queue, writeFromQueue(), and writing.
Referenced by writeStringMessage().
void Client.writeMessageFrom | ( | Client | client, |
String | message | ||
) |
Send a message from a specific client
client | the message is sent from |
message | to send |
Definition at line 144 of file Client.java.
References client, reader, and writeStringMessage().
void Client.writeStringMessage | ( | String | string | ) |
Sends a message
string | the message |
Definition at line 135 of file Client.java.
References writeMessage().
Referenced by writeMessageFrom().
|
private |
Definition at line 60 of file Client.java.
Referenced by Client(), close(), read(), and writeBuffer().
|
private |
Definition at line 63 of file Client.java.
Referenced by appendMessage(), and nextMessage().
|
private |
Definition at line 65 of file Client.java.
Referenced by writeFromQueue(), and writeMessage().
|
private |
Definition at line 61 of file Client.java.
Referenced by Client(), run(), setReader(), and writeMessageFrom().
|
private |
Definition at line 62 of file Client.java.
Referenced by getUserName(), and setUserName().
|
private |
Definition at line 66 of file Client.java.
Referenced by writeFromQueue(), and writeMessage().