mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-05-19 17:29:39 +00:00
fix[channel]: wrong channel object was used
This commit is contained in:
@@ -52,8 +52,6 @@ public abstract class AbstractServer<C extends Channel> extends ChannelInitializ
|
||||
|
||||
protected ChannelFuture channelFuture;
|
||||
|
||||
protected Channel channel;
|
||||
|
||||
public AbstractServer(HostAndPort host) {
|
||||
this.hostAddress = host.getHost();
|
||||
this.port = host.getPort();
|
||||
@@ -91,7 +89,6 @@ public abstract class AbstractServer<C extends Channel> extends ChannelInitializ
|
||||
// 异步
|
||||
channelFuture = bootstrap.bind(hostAddress, port);
|
||||
channelFuture.syncUninterruptibly();
|
||||
channel = channelFuture.channel();
|
||||
|
||||
allServers.add(this);
|
||||
|
||||
@@ -111,14 +108,6 @@ public abstract class AbstractServer<C extends Channel> extends ChannelInitializ
|
||||
logger.warn(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
if (channel != null) {
|
||||
try {
|
||||
channel.close();
|
||||
} catch (Exception e) {
|
||||
logger.warn(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized static void shutdownAllServers() {
|
||||
|
||||
@@ -32,7 +32,7 @@ public class TcpServer extends AbstractServer<SocketChannel> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initChannel(SocketChannel socketChannel) throws Exception {
|
||||
protected void initChannel(SocketChannel channel) throws Exception {
|
||||
channel.pipeline().addLast(new IdleStateHandler(0, 0, 180));
|
||||
channel.pipeline().addLast(new ServerIdleHandler());
|
||||
channel.pipeline().addLast(new TcpCodecHandler());
|
||||
|
||||
@@ -57,7 +57,6 @@ public class UdpServer extends AbstractServer<Channel> {
|
||||
// 异步
|
||||
channelFuture = bootstrap.bind(hostAddress, port);
|
||||
channelFuture.syncUninterruptibly();
|
||||
channel = channelFuture.channel();
|
||||
|
||||
allServers.add(this);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user