Class Client

java.lang.Object
com.houseofkraft.nsp.networking.Client

public class Client extends Object
  • Constructor Details

  • 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

      public DataInputStream getInputStream()
      Returns:
      Input Stream
    • getOutputStream

      public DataOutputStream getOutputStream()
      Returns:
      Output Stream
    • resetKeepAlive

      public Client 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

      public Socket getSocket()
      Returns:
      Socket Instance
    • getIP

      public String getIP(boolean port)
      Parameters:
      port - Return the address with the Port
      Returns:
      Bound IP Address with Port Option
    • getID

      public String getID()
      Returns:
      ID Identifier
    • setID

      public void setID(String hostname)
      Changes the Identifier Hostname when the mode is changed to ID.
      Parameters:
      hostname - Hostname
    • setIDMode

      public Client setIDMode(boolean idMode)
      Sets the Identifier mode to either ID Mode or IP Mode.
      Parameters:
      idMode - ID Mode
      Returns:
      Client Builder
    • setThread

      public Client setThread(ClientManager handlerThread)
      Sets the Client Handler Thread for the Server.
      Parameters:
      handlerThread - Client Handler Thread
      Returns:
      Client Builder
    • getThread

      public ClientManager getThread()
      Returns:
      Client Manager Thread
    • startThread

      public Client startThread()
      Starts the Client Manager Thread
    • getIdentifier

      public String getIdentifier(boolean port)
      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, IOException
      Reads 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, IOException
      Reads 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.