|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.asdf.server.ClientConnection
public class ClientConnection
Contains functionality required to manage single channel with multiple recipients and senders. This class is accessed from multiple threads. Send is accessed from Game instances and don't need synchronization as it doesn't modify class's data. Server's single thread is the only one that modifies data so synchronization isn't needed.
Nested Class Summary | |
---|---|
static class |
ClientConnection.State
Possible states for data receiving. |
Field Summary | |
---|---|
boolean |
disposing
|
java.nio.ByteBuffer |
msgBuffer
|
int |
size
|
java.nio.ByteBuffer |
sizeBuffer
|
Constructor Summary | |
---|---|
ClientConnection(Server server,
java.nio.channels.SelectionKey key,
java.net.InetSocketAddress address)
Constructs ClientConnection. |
Method Summary | |
---|---|
Account |
getAccount()
Getter for account |
java.lang.String |
getAddress()
Getter for client ip string |
java.lang.String |
getAddressString()
Getter for client remote address string |
java.nio.channels.SelectionKey |
getKey()
Getter method for connection channel key. |
java.net.InetAddress |
getRawAddress()
Getter for client ip address |
ClientConnection.State |
getReceivingState()
Getter for receivingState |
Server |
getServer()
Getter for server |
void |
login(Account acc)
Mark connection authenticated. |
void |
logout()
Mark connection unauthenticated. |
void |
msgReceived()
MsgReceived Called when message has been received. |
void |
send(byte[] data)
Sends data to recipients. |
void |
send(Message msg)
Sends message with it's size to client. |
void |
sizeReceived()
SizeReceived Is called when size has been read from the socket. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public java.nio.ByteBuffer sizeBuffer
public java.nio.ByteBuffer msgBuffer
public int size
public boolean disposing
Constructor Detail |
---|
public ClientConnection(Server server, java.nio.channels.SelectionKey key, java.net.InetSocketAddress address)
server
- Method Detail |
---|
public Server getServer()
public Account getAccount()
public ClientConnection.State getReceivingState()
public java.nio.channels.SelectionKey getKey()
public java.lang.String getAddressString()
public java.lang.String getAddress()
public java.net.InetAddress getRawAddress()
public void sizeReceived() throws java.io.IOException
java.io.IOException
public void msgReceived() throws java.io.IOException
java.io.IOException
public void send(Message msg)
msg
- Message to send
java.io.IOException
public void send(byte[] data) throws java.io.IOException
data
-
java.io.IOException
public void login(Account acc)
acc
- Valid accountpublic void logout()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |