| | |
| | | package com.ard.tianyu.netty; |
| | | |
| | | import com.ard.tianyu.config.TyConfiguration; |
| | | import com.ard.tianyu.model.cache.TyTcpServerCache; |
| | | import com.ard.tianyu.netty.handler.ClientHandler; |
| | | import com.ard.tianyu.netty.handler.MessageProtocolDecoder; |
| | | import com.ard.tianyu.netty.handler.MessageProtocolEncoder; |
| | |
| | | ChannelFuture future = bootstrap.connect(host, port).addListener((ChannelFuture futureListener) -> { |
| | | if (futureListener.isSuccess()) { |
| | | log.info("连接天宇TCP服务器成功【{}:{}】", host, port); |
| | | TyTcpServerCache.putTcpServerCache(host + ":" + port, true); |
| | | } else { |
| | | final EventLoop eventLoop = futureListener.channel().eventLoop(); |
| | | eventLoop.schedule(() -> { |
| | | log.info("连接天宇TCP服务器失败【{}:{}】,正尝试重连...", host, port); |
| | | TyTcpServerCache.putTcpServerCache(host + ":" + port, false); |
| | | try { |
| | | initConnection(host, port); |
| | | } catch (Exception e) { |