Package com.example.client.app
Class BaseClientListener
java.lang.Object
java.lang.Thread
com.example.common.listener.BaseListener
com.example.client.app.BaseClientListener
The BaseClientListener is a subclass of BaseListener that handles the communication with clients in the chat application.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class com.example.common.listener.BaseListener
streamIO, transportListener
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorsConstructorDescriptionBaseClientListener
(int portIn, StreamIO streamIO, TransportFactory transportFactory) Constructs a BaseClientListener with the specified input port, StreamIO, and TransportFactory. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
worker()
Continuously waits for incoming messages from clients, prints the message, and closes the connection.Methods inherited from class com.example.common.listener.BaseListener
run
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Constructor Details
-
BaseClientListener
Constructs a BaseClientListener with the specified input port, StreamIO, and TransportFactory.- Parameters:
portIn
- the input port number to listen for incoming connectionsstreamIO
- the StreamIO object for handling input and output streamstransportFactory
- the TransportFactory object for creating a listener
-
-
Method Details
-
worker
Continuously waits for incoming messages from clients, prints the message, and closes the connection.- Specified by:
worker
in classBaseListener
- Throws:
IOException
- if an error occurs while receiving or handling the message
-