+ super.sessionUp();
+ }
+
+ /**
+ * Close this session after next message is sent.
+ * Suitable for close rpc that needs to send ok response before the session is closed.
+ */
+ public void delayedClose() {
+ this.delayedClose = true;
+ }
+
+ @Override
+ public ChannelFuture sendMessage(final NetconfMessage netconfMessage) {
+ final ChannelFuture channelFuture = super.sendMessage(netconfMessage);
+ // delayed close was set, close after the message was sent
+ if(delayedClose) {
+ channelFuture.addListener(new ChannelFutureListener() {
+ @Override
+ public void operationComplete(final ChannelFuture future) throws Exception {
+ close();
+ }
+ });
+ }
+ return channelFuture;