Package com.houseofkraft.nsp.networking
Class Client
java.lang.Object
com.houseofkraft.nsp.networking.Client
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidban()Bans the Client from the ServergetID()getIdentifier(boolean port)getIP(boolean port)longlongbooleanisBanned()booleanisKicked()voidkick()Kicks the Client from the ServerHashMap<byte[],byte[]>readMessage(PacketParser parser)Reads the Message using the built-in InputStream.readMessageString(PacketParser parser)Reads the Message using the built-in InputStream.Resets the Keep Alive to the specified seconds delay in the Options.booleansendMessage(byte[] packet)Sends a Message using the built-in OutputStream.voidChanges the Identifier Hostname when the mode is changed to ID.setIDMode(boolean idMode)Sets the Identifier mode to either ID Mode or IP Mode.setThread(ClientManager handlerThread)Sets the Client Handler Thread for the Server.Starts the Client Manager Threadvoidstop()Kicks the Client from the Server
-
Constructor Details
-
Client
- Throws:
IOException
-
-
Method Details
-
ban
public void ban()Bans the Client from the Server -
kick
public void kick()Kicks the Client from the Server -
stop
public void stop()Kicks the Client from the Server -
isKicked
public boolean isKicked()- Returns:
- If the Client is Kicked
-
isBanned
public boolean isBanned()- Returns:
- If the Client is Banned
-
getKeepAlive
public long getKeepAlive()- Returns:
- Keep Alive Milliseconds
-
getInputStream
- Returns:
- Input Stream
-
getOutputStream
- Returns:
- Output Stream
-
resetKeepAlive
Resets the Keep Alive to the specified seconds delay in the Options.- Returns:
- Client Builder
-
getTimestamp
public long getTimestamp()- Returns:
- Initial Connection Timestamp
-
getSocket
- Returns:
- Socket Instance
-
getIP
- Parameters:
port- Return the address with the Port- Returns:
- Bound IP Address with Port Option
-
getID
- Returns:
- ID Identifier
-
setID
Changes the Identifier Hostname when the mode is changed to ID.- Parameters:
hostname- Hostname
-
setIDMode
Sets the Identifier mode to either ID Mode or IP Mode.- Parameters:
idMode- ID Mode- Returns:
- Client Builder
-
setThread
Sets the Client Handler Thread for the Server.- Parameters:
handlerThread- Client Handler Thread- Returns:
- Client Builder
-
getThread
- Returns:
- Client Manager Thread
-
startThread
Starts the Client Manager Thread -
getIdentifier
- Parameters:
port- Return with Port Included- Returns:
- Preferred Identifier
-
sendMessage
public boolean sendMessage(byte[] packet)Sends a Message using the built-in OutputStream.- Parameters:
packet- ByteArray Packet- Returns:
- Client Builder
-
readMessage
public HashMap<byte[],byte[]> readMessage(PacketParser parser) throws GeneralSecurityException, IOExceptionReads the Message using the built-in InputStream.- Parameters:
parser- Packet Parser- Returns:
- Read Message HashMap
- Throws:
GeneralSecurityException- If there is a decryption error.IOException- If there is a socket error.
-
readMessageString
public HashMap<String,String> readMessageString(PacketParser parser) throws GeneralSecurityException, IOExceptionReads the Message using the built-in InputStream.- Parameters:
parser- Packet Parser- Returns:
- Read Message String
- Throws:
GeneralSecurityException- If there is a decryption error.IOException- If there is a socket error.
-