Skip to content
This repository was archived by the owner on Oct 6, 2020. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/main/java/de/uniluebeck/itm/nettyrxtx/RXTXChannelSink.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.net.SocketAddress;
import java.util.TooManyListenersException;
import java.util.concurrent.Executor;

Expand Down Expand Up @@ -75,8 +76,12 @@ private static class ConnectRunnable implements Runnable {
private DefaultChannelFuture channelFuture;

private RXTXChannelSink channelSink;
private Channel channel;
private SocketAddress remoteAddress;

private ConnectRunnable(final DefaultChannelFuture channelFuture, final RXTXChannelSink channelSink) {
private ConnectRunnable(final DefaultChannelFuture channelFuture, final RXTXChannelSink channelSink, Channel channel, SocketAddress remoteAddress) {
this.channel = channel;
this.remoteAddress = remoteAddress;
this.channelFuture = channelFuture;
this.channelSink = channelSink;
}
Expand All @@ -90,6 +95,9 @@ public void run() {
connectInternal();
log.debug("Successfully connected.");
channelFuture.setSuccess();
Channels.fireChannelConnected(channel, remoteAddress);
log.debug("Fired Channel Connected.");

} catch (Exception e) {
log.warn("" + e, e);
channelFuture.setFailure(e);
Expand Down Expand Up @@ -317,7 +325,7 @@ public void eventSunk(final ChannelPipeline pipeline, final ChannelEvent e) thro
case CONNECTED:
if (value != null) {
remoteAddress = (RXTXDeviceAddress) value;
executor.execute(new ConnectRunnable((DefaultChannelFuture) future, this));
executor.execute(new ConnectRunnable((DefaultChannelFuture) future, this, pipeline.getChannel(), remoteAddress));
} else {
executor.execute(new DisconnectRunnable((DefaultChannelFuture) future, this));
}
Expand All @@ -344,4 +352,4 @@ public void eventSunk(final ChannelPipeline pipeline, final ChannelEvent e) thro
}
}

}
}