sessionListener.onMessage(thisInstance(), netconfMessage);
}
+ protected void handleError(final Exception failure) {
+ LOG.debug("handling incoming error");
+ sessionListener.onError(thisInstance(), failure);
+ }
+
@Override
public ChannelFuture sendMessage(final NetconfMessage netconfMessage) {
// From: https://github.com/netty/netty/issues/3887
protected void endOfInput() {
LOG.debug("Session {} end of input detected while session was in state {}", this, up ? "up" : "initialized");
if (up) {
- this.sessionListener.onSessionDown(thisInstance(), new EOFException("End of input"));
+ sessionListener.onSessionDown(thisInstance(), new EOFException("End of input"));
}
}
protected void sessionUp() {
LOG.debug("Session {} up", this);
sessionListener.onSessionUp(thisInstance());
- this.up = true;
+ up = true;
}
@Override
}
protected final void replaceMessageEncoderAfterNextMessage(final ChannelHandler handler) {
- this.delayedEncoder = handler;
+ delayedEncoder = handler;
}
protected final void replaceChannelHandler(final String handlerName, final ChannelHandler handler) {
@Override
protected final void channelRead0(final ChannelHandlerContext ctx, final Object msg) {
LOG.debug("Message was received: {}", msg);
- handleMessage((NetconfMessage) msg);
+ if (msg instanceof NetconfMessage message) {
+ handleMessage(message);
+ } else if (msg instanceof Exception failure) {
+ handleError(failure);
+ } else {
+ LOG.warn("Ignoring unexpected message {}", msg);
+ }
}
@Override