public abstract class Client<T extends Connection<?>>
extends java.lang.Object
| Constructor and Description |
|---|
Client(T connection)
Construct a new Client
|
| Modifier and Type | Method and Description |
|---|---|
void |
close(WritablePacket<? extends Client<T>> packet)
Sends the packet and close the underlying Connection to the client.
|
abstract boolean |
decrypt(byte[] data,
int offset,
int size)
Decrypt the data in-place
|
protected void |
disconnect() |
abstract int |
encrypt(byte[] data,
int offset,
int size)
Encrypt the data in-place.
|
java.lang.String |
getHostAddress() |
boolean |
isConnected() |
abstract void |
onConnected()
Handles the client's connection.
|
protected abstract void |
onDisconnection()
Handles the client's disconnection.
|
protected void |
writePacket(WritablePacket<? extends Client<T>> packet)
Sends a packet to this client.
|
public Client(T connection)
connection - - The Connection to the client.java.lang.IllegalArgumentException - if the connection is null or closed.protected void writePacket(WritablePacket<? extends Client<T>> packet)
packet - to be sent.public void close(WritablePacket<? extends Client<T>> packet)
packet - to be sent before the connection is closed.protected final void disconnect()
public java.lang.String getHostAddress()
public boolean isConnected()
public abstract int encrypt(byte[] data,
int offset,
int size)
data - - the data to be encryptedoffset - - the initial index to be encryptedsize - - the length of data to be encryptedpublic abstract boolean decrypt(byte[] data,
int offset,
int size)
data - - data to be decryptedoffset - - the initial index to be encrypted.size - - the length of data to be encrypted.protected abstract void onDisconnection()
public abstract void onConnected()