| | |
| | | import com.ruoyi.dataInterchange.util.jtt809.packet.common.OuterPacket; |
| | | import io.netty.channel.ChannelHandlerContext; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | |
| | | /** |
| | |
| | | @Component |
| | | public class UPLinkTestReqService { |
| | | |
| | | @Resource |
| | | private RedisTemplate redisTemplate; |
| | | |
| | | |
| | | /** |
| | | * 主链路连接保持 |
| | |
| | | * @param out |
| | | */ |
| | | public void linkTest(ChannelHandlerContext ctx, OuterPacket out) { |
| | | if (!redisTemplate.hasKey("login:" + out.getGnsscenterId())) { |
| | | log.error("链路还未登录校验,拒绝连接"); |
| | | ctx.close(); |
| | | return; |
| | | } |
| | | int gnsscenterId = out.getGnsscenterId(); |
| | | ChannelMap.addServerChannel(gnsscenterId, ctx.channel()); |
| | | OuterPacket rep = new OuterPacket(DataType.UP_LINKTEST_RSP.getCode(), null); |
| | | log.info("主链路连接保持应答({}):{}", DataType.UP_LINKTEST_RSP.getCode(), JSON.toJSONString(rep)); |
| | | ctx.writeAndFlush(rep); |
| | | ctx.flush(); |
| | | } |
| | | } |