Package org.flasby.util
Class Dispatcher<T>
java.lang.Object
org.flasby.util.Dispatcher<T>
- Type Parameters:
T
-
invokes a list of registered Callbacks with either an error or a success
message.
Can be used to easily add event listeners to event-driven, network socket listeners.
I use it to dispatch messages to registers listeners:
Dispatcher<Msg> dispatcher = new Dispatcher<Msg>();
Msg msg;
do {
try {;
msg = readMessage();
if ( msg!=null ) {
dispatcher.dispatch(msg);
}
} catch ( Exception ioe ) {
ex = ioe;
dispatcher.dispatchError(ioe);
}
} while ( ex==null && !(msg instanceof EndOfSessionMsg) );
- Author:
- steve
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
is a polite thing to do.void
void
int
void
unregister
(int idFrom)
-
Constructor Details
-
Dispatcher
public Dispatcher()
-
-
Method Details
-
dispatch
-
dispatchError
-
register
-
unregister
public void unregister(int idFrom) -
close
public void close()is a polite thing to do.
-