fix 服务端添加心跳监听

This commit is contained in:
wujiawei 2024-01-03 14:41:48 +08:00
parent 4f8d1d206c
commit cbd0d7c954
4 changed files with 44 additions and 44 deletions

View File

@ -24,7 +24,7 @@
<dependency>
<groupId>top.wu2020</groupId>
<artifactId>wu-framework-web</artifactId>
<version>1.1.9-JDK1.8-SNAPSHOT</version>
<version>1.1.9-JDK1.8</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@ -70,9 +70,7 @@ public class ProxySocket {
});
log.info("连接服务端IP:{},连接服务端端口:{}",Constant.serverIp, Constant.serverPort);
bootstrap.connect(Constant.serverIp, Constant.serverPort).addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
bootstrap.connect(Constant.serverIp, Constant.serverPort).addListener((ChannelFutureListener) future -> {
if (future.isSuccess()) {
System.out.println("连接服务端成功");
// 客户端链接代理服务器成功
@ -117,7 +115,6 @@ public class ProxySocket {
}
}, 2, TimeUnit.SECONDS);
}
}
});
}
}

View File

@ -7,7 +7,9 @@ import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.util.internal.StringUtil;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class RealSocket {
static EventLoopGroup eventLoopGroup = new NioEventLoopGroup();
@ -41,6 +43,7 @@ public class RealSocket {
}
});
log.info("代理客户端本地端口:{}",Constant.realPort);
bootstrap.connect("127.0.0.1", Constant.realPort).addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {

View File

@ -34,7 +34,7 @@
<dependency>
<groupId>top.wu2020</groupId>
<artifactId>wu-framework-web</artifactId>
<version>1.1.9-JDK1.8-SNAPSHOT</version>
<version>1.1.9-JDK1.8</version>
</dependency>
</dependencies>
</project>