try {
protocol = newProtocol();
} catch (ProtocolException e) {
throw new NodeException("Can not create protocol", e);
}
Protocol curProtocol = protocol;
while ( null != curProtocol ) {
if ( curProtocol instanceof CallbackSocketProtocol ) {
((CallbackSocketProtocol) curProtocol).setListener(
new SocketProtocolListener() {
public void onClose() {
msgOut = null;
inDispatcher = null;
if ( null != listener ) {
listener.onClose();
}
}
});
break;
}
curProtocol = curProtocol.getDownProtocol();
}
if ( false == curProtocol instanceof CallbackSocketProtocol ) {
throw new AssertionError("No CallbackSocketProtocol.");
}