Class ClientHandler

java.lang.Object
java.lang.Thread
me.remigio07.chatplugin.api.proxy.util.socket.ClientHandler
All Implemented Interfaces:
Runnable

public class ClientHandler extends Thread
Client socket handler. Obtain instances of this class by listening to ClientConnectionEvent.
  • Field Details

  • Method Details

    • run

      @Deprecated public void run()
      Deprecated.
      Internal use only; do not call this method.
      Automatic packet listener.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
      See Also:
    • sendPacket

      public void sendPacket(PacketSerializer packet)
      Sends a packet to this client handler.
      Parameters:
      packet - Packet to send
      Throws:
      IllegalStateException - If PacketSerializer.toArray() fails
    • disconnect

      public void disconnect(String reason) throws IOException
      Manually disconnects this client from the server.
      Parameters:
      reason - Disconnection's reason
      Throws:
      IOException - If something goes wrong
      IllegalArgumentException - If reason.length() > 255
      See Also:
    • getServer

      public Server getServer()
      Gets this client handler's server.
      Returns:
      Client handler's server
    • getSocket

      public Socket getSocket()
      Gets this client handler's socket.
      Returns:
      Client handler's socket
    • getID

      public String getID()
      Gets this client handler's ID.
      Returns:
      Client handler's ID
    • getInput

      public DataInputStream getInput()
      Gets this client handler's data input stream.
      Returns:
      Client handler's input stream
    • getOutput

      public DataOutputStream getOutput()
      Gets this client handler's data output stream.
      Returns:
      Client handler's output stream
    • isValidClientID

      public static boolean isValidClientID(String clientID)
      Checks if the specified String is a valid client ID.
      Parameters:
      clientID - Client ID to check
      Returns:
      Whether the specified client ID is valid
      See Also: