Class ClientHandler
java.lang.Object
java.lang.Thread
me.remigio07.chatplugin.api.proxy.util.socket.ClientHandler
- All Implemented Interfaces:
Runnable
Client socket handler. Obtain instances of this
class by listening to
ClientConnectionEvent.-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternPattern representing the allowed client IDs.Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Method Summary
Modifier and TypeMethodDescriptionvoiddisconnect(String reason) Manually disconnects this client from the server.getID()Gets this client handler's ID.getInput()Gets this client handler's data input stream.Gets this client handler's data output stream.Gets this client handler's server.Gets this client handler's socket.static booleanisValidClientID(String clientID) Checks if the specified String is a valid client ID.voidrun()Deprecated.Internal use only; do not call this method.voidsendPacket(PacketSerializer packet) Sends a packet to this client handler.Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
CLIENT_ID_PATTERN
Pattern representing the allowed client IDs.Regex:
^[a-zA-Z0-9-_]{2,36}$- See Also:
-
-
Method Details
-
run
Deprecated.Internal use only; do not call this method.Automatic packet listener. -
sendPacket
Sends a packet to this client handler.- Parameters:
packet- Packet to send- Throws:
IllegalStateException- IfPacketSerializer.toArray()fails
-
disconnect
Manually disconnects this client from the server.- Parameters:
reason- Disconnection's reason- Throws:
IOException- If something goes wrongIllegalArgumentException- Ifreason.length() > 255- See Also:
-
getServer
Gets this client handler's server.- Returns:
- Client handler's server
-
getSocket
Gets this client handler's socket.- Returns:
- Client handler's socket
-
getID
Gets this client handler's ID.- Returns:
- Client handler's ID
-
getInput
Gets this client handler's data input stream.- Returns:
- Client handler's input stream
-
getOutput
Gets this client handler's data output stream.- Returns:
- Client handler's output stream
-
isValidClientID
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:
-