diff --git a/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java b/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java index 685a7b1..f56de83 100644 --- a/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java +++ b/src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java @@ -138,7 +138,7 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { // 从缓存获取SDBP-AST-EPH星历数 //if (Integer.parseInt(starsAsycServerPort) == channel.localAddress().getPort()) { //if (AST_POS_CMD.equals(recvmg)) { - if (AST_POS_CMD.equals(msg)) { + if (AST_EPH_CMD_BYTE.equals(msg)) { channelAns = nettyServerHandler.dipperDataAsyncTaskService.getAstEPH(); } @@ -146,29 +146,15 @@ public class NettyServerHandler extends ChannelInboundHandlerAdapter { if (channelAns != null) { buf = Unpooled.buffer(channelAns.getBytes().length); buf.writeBytes(channelAns.getBytes("GBK")); + ctx.writeAndFlush(buf); } // 最后把SDBP-AST-TIME、SDBP-AST-POS、SDBP-AST-EPH并包一起发给设备。 // 设备采用16进制获取数据,则代理服务器也是采用16进制返回数据。 // 通知客户端链消息发送成功 - ctx.writeAndFlush(buf); //ctx.write("你也好哦"); //ctx.flush(); } -// @Override -// public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) -// throws Exception { -// if (msg instanceof HttpRequest) { -// HttpRequest mReq = (HttpRequest) msg; -// String clientIP = mReq.headers().get("X-Forwarded-For"); -// if (clientIP == null) { -// InetSocketAddress insocket = (InetSocketAddress) ctx.channel() -// .remoteAddress(); -// clientIP = insocket.getAddress().getHostAddress(); -// } -// } -// } - /** * 发生异常触发 */ diff --git a/src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java b/src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java index 54dc4ec..6aa2edc 100644 --- a/src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java +++ b/src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java @@ -29,11 +29,11 @@ import java.net.InetSocketAddress; */ @Slf4j @Component -@NacosPropertySource(dataId="dipperposition-service", autoRefreshed=true) +//@NacosPropertySource(dataId="dipperposition-service", autoRefreshed=true) public class DipperPositionServer { - @NacosValue("position-server.serverAddr") - private String myServerAddr; + //@NacosValue("position-server.serverAddr") + //private String myServerAddr; private String serverAddr; private Integer starsAsycPort; @@ -70,7 +70,7 @@ public class DipperPositionServer { ChannelFuture channelFuture3 = bootstrap.bind(socketAddress).sync(); log.info("星历服务器启动开始监听端口: {}", starsAsycPort); - log.info("服务器: {}", myServerAddr); + //log.info("服务器: {}", myServerAddr); channelFuture3.addListener(future -> { if (future.isSuccess()){ System.out.println("start success");