void setReadEventDispatcher(Dispatcher dispatcher) {
Dispatcher oldDispatcher = readEventDispatcher;
readEventDispatcher = dispatcher;
if (oldDispatcher != null) {
oldDispatcher.stop();
}
}
void setWriteEventDispatcher(Dispatcher dispatcher) {
Dispatcher oldDispatcher = writeEventDispatcher;