Bladeren bron

修改到docker外运行环境

tags/v1.0.0^2
林万龙 3 jaren geleden
bovenliggende
commit
f512d4a856
2 gewijzigde bestanden met toevoegingen van 6 en 20 verwijderingen
  1. +2
    -16
      src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java
  2. +4
    -4
      src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java

+ 2
- 16
src/main/java/com/telpo/dipperposition/handler/NettyServerHandler.java Bestand weergeven

@@ -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();
// }
// }
// }

/**
* 发生异常触发
*/


+ 4
- 4
src/main/java/com/telpo/dipperposition/server/DipperPositionServer.java Bestand weergeven

@@ -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");


Laden…
Annuleren
Opslaan