| | |
| | | import org.springframework.boot.ApplicationArguments; |
| | | import org.springframework.boot.ApplicationRunner; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | if (!nettyTcpConfig.getEnabled()) { |
| | | return; |
| | | } |
| | | //EventLoopGroup group = new NioEventLoopGroup(); |
| | | //Bootstrap bootstrap = new Bootstrap(); |
| | | //bootstrap.group(group) |
| | | // .channel(NioSocketChannel.class) |
| | | // .option(ChannelOption.TCP_NODELAY, true) |
| | | // .option(ChannelOption.SO_KEEPALIVE, true) |
| | | // .handler(new DynamicClientInitializer()); |
| | | EventLoopGroup group = new NioEventLoopGroup(); |
| | | Bootstrap bootstrap = new Bootstrap(); |
| | | bootstrap.group(group) |
| | | .channel(NioSocketChannel.class) |
| | | .option(ChannelOption.TCP_NODELAY, true) |
| | | .option(ChannelOption.SO_KEEPALIVE, true) |
| | | .handler(new DynamicClientInitializer()); |
| | | List<ArdEquipRadar> ardEquipRadars = ardEquipRadarService.selectArdEquipRadarList(new ArdEquipRadar()); |
| | | for (ArdEquipRadar ardEquipRadar : ardEquipRadars) { |
| | | String host = ardEquipRadar.getIp(); |
| | | Integer port = Integer.valueOf(ardEquipRadar.getPort()); |
| | | log.debug("TCP client try to connect radar【:" + host + ":" + port+"】"); |
| | | // connectServer(ardEquipRadar);//连接每一个雷达服务 |
| | | // connect(bootstrap, ardEquipRadar); |
| | | BootNettyClientThread thread = new BootNettyClientThread(host,port); |
| | | thread.start(); |
| | | log.debug("TCP client try to connect radar【:" + host + ":" + port + "】"); |
| | | // connectServer(ardEquipRadar);//连接每一个雷达服务 |
| | | connect(bootstrap, ardEquipRadar); |
| | | } |
| | | } |
| | | } |