cleanedup the sctp notification handler
This commit is contained in:
parent
af943b7502
commit
71fd0231da
@ -23,6 +23,7 @@ import com.sun.nio.sctp.PeerAddressChangeNotification;
|
|||||||
import com.sun.nio.sctp.SendFailedNotification;
|
import com.sun.nio.sctp.SendFailedNotification;
|
||||||
import com.sun.nio.sctp.ShutdownNotification;
|
import com.sun.nio.sctp.ShutdownNotification;
|
||||||
|
|
||||||
|
import io.netty.channel.ChannelPipeline;
|
||||||
import io.netty.channel.Channels;
|
import io.netty.channel.Channels;
|
||||||
import io.netty.logging.InternalLogger;
|
import io.netty.logging.InternalLogger;
|
||||||
import io.netty.logging.InternalLoggerFactory;
|
import io.netty.logging.InternalLoggerFactory;
|
||||||
@ -36,11 +37,11 @@ class SctpNotificationHandler extends AbstractNotificationHandler {
|
|||||||
InternalLoggerFactory.getInstance(SctpNotificationHandler.class);
|
InternalLoggerFactory.getInstance(SctpNotificationHandler.class);
|
||||||
|
|
||||||
private final SctpChannelImpl sctpChannel;
|
private final SctpChannelImpl sctpChannel;
|
||||||
private final SctpWorker sctpWorker;
|
private final ChannelPipeline pipeline;
|
||||||
|
|
||||||
public SctpNotificationHandler(SctpChannelImpl sctpChannel, SctpWorker sctpWorker) {
|
SctpNotificationHandler(SctpChannelImpl sctpChannel) {
|
||||||
this.sctpChannel = sctpChannel;
|
this.sctpChannel = sctpChannel;
|
||||||
this.sctpWorker = sctpWorker;
|
this.pipeline = sctpChannel.getPipeline();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -49,12 +50,6 @@ class SctpNotificationHandler extends AbstractNotificationHandler {
|
|||||||
return HandlerResult.CONTINUE;
|
return HandlerResult.CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerResult handleNotification(Notification notification, Object o) {
|
|
||||||
fireNotificationReceived(notification, o);
|
|
||||||
return HandlerResult.CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerResult handleNotification(PeerAddressChangeNotification notification, Object o) {
|
public HandlerResult handleNotification(PeerAddressChangeNotification notification, Object o) {
|
||||||
fireNotificationReceived(notification, o);
|
fireNotificationReceived(notification, o);
|
||||||
@ -69,11 +64,11 @@ class SctpNotificationHandler extends AbstractNotificationHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerResult handleNotification(ShutdownNotification notification, Object o) {
|
public HandlerResult handleNotification(ShutdownNotification notification, Object o) {
|
||||||
sctpWorker.close(sctpChannel, Channels.succeededFuture(sctpChannel));
|
Channels.fireChannelDisconnected(sctpChannel);
|
||||||
return HandlerResult.RETURN;
|
return HandlerResult.RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fireNotificationReceived(Notification notification, Object o) {
|
private void fireNotificationReceived(Notification notification, Object o) {
|
||||||
sctpChannel.getPipeline().sendUpstream(new SctpNotificationEvent(sctpChannel, notification, o));
|
pipeline.sendUpstream(new SctpNotificationEvent(sctpChannel, notification, o));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ class SctpWorker implements Runnable {
|
|||||||
|
|
||||||
boolean server = !(channel instanceof SctpClientChannel);
|
boolean server = !(channel instanceof SctpClientChannel);
|
||||||
Runnable registerTask = new RegisterTask(channel, future, server);
|
Runnable registerTask = new RegisterTask(channel, future, server);
|
||||||
notificationHandler = new SctpNotificationHandler(channel, this);
|
notificationHandler = new SctpNotificationHandler(channel);
|
||||||
Selector selector;
|
Selector selector;
|
||||||
|
|
||||||
synchronized (startStopLock) {
|
synchronized (startStopLock) {
|
||||||
|
Loading…
Reference in New Issue
Block a user