Package com.example.common.listener
Class BaseListener
java.lang.Object
java.lang.Thread
com.example.common.listener.BaseListener
- Direct Known Subclasses:
BaseClientListener
,BaseServerListener
BaseListener class implements a basic listener functionality for receiving and sending messages.
It extends Thread class and implements the Listener interface.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
FieldsFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorsConstructorDescriptionBaseListener
(int portIn, StreamIO streamIO, TransportFactory transportFactory) Constructor for BaseListener class. -
Method Summary
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
-
Field Details
-
transportListener
-
streamIO
-
-
Constructor Details
-
BaseListener
Constructor for BaseListener class.- 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
-
run
public void run()Continuously waits for incoming messages and processes them using the worker method. -
worker
Abstract method that must be implemented by subclasses to define the processing of incoming messages.- Throws:
IOException
- if an error occurs while receiving or processing the message
-