- // TODO we should also read from error stream and at least log from that
-
- sshReadAsyncListener = new AsyncSshHandlerReader(new AutoCloseable() {
- @Override
- public void close() throws Exception {
- AsyncSshHandler.this.disconnect(ctx, ctx.newPromise());
- }
- }, new AsyncSshHandlerReader.ReadMsgHandler() {
- @Override
- public void onMessageRead(final ByteBuf msg) {
- ctx.fireChannelRead(msg);
- }
- }, channel.toString(), channel.getAsyncOut());
-
- // if readAsyncListener receives immediate close, it will close this handler and closing this handler sets channel variable to null
- if(channel != null) {
- sshWriteAsyncHandler = new AsyncSshHandlerWriter(channel.getAsyncIn());
- ctx.fireChannelActive();
- }
+ sshWriteAsyncHandler = new AsyncSshHandlerWriter(channel.getAsyncIn());
+ ctx.fireChannelActive();
+ channel.onClose(() -> disconnect(ctx, ctx.newPromise()));