Commit 8a26fc40 authored by duanruiming's avatar duanruiming

[update] netty异常优化

parent ef4be998
...@@ -10,8 +10,8 @@ import java.util.List; ...@@ -10,8 +10,8 @@ import java.util.List;
@SuppressWarnings("all") @SuppressWarnings("all")
public class Constants { public class Constants {
public static final String COMMAND_HEAD = "7e"; public static final String COMMAND_HEAD = "0x7e";
public static final String COMMAND_TAIL = "7d"; public static final String COMMAND_TAIL = "0x7d";
public static final String COMMAND_HEARTBEAT = "01000100000001000170"; public static final String COMMAND_HEARTBEAT = "01000100000001000170";
public static final String COMMAND_SET_IP = ""; public static final String COMMAND_SET_IP = "";
......
...@@ -81,11 +81,6 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<DatagramPack ...@@ -81,11 +81,6 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<DatagramPack
} }
} }
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
super.exceptionCaught(ctx, cause);
}
private CommandPojo getCommandPojo(String key, String data) { private CommandPojo getCommandPojo(String key, String data) {
CrossInfoPO crossInfo = crossInfoCache.getCrossInfo(key); CrossInfoPO crossInfo = crossInfoCache.getCrossInfo(key);
CommandPojo commandPojo = new CommandPojo(); CommandPojo commandPojo = new CommandPojo();
...@@ -96,4 +91,8 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<DatagramPack ...@@ -96,4 +91,8 @@ public class NettyServerHandler extends SimpleChannelInboundHandler<DatagramPack
commandPojo.setResponseMsg(data); commandPojo.setResponseMsg(data);
return commandPojo; return commandPojo;
} }
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
}
} }
package net.wanji.com.service.protocol.impl.base;
import lombok.extern.slf4j.Slf4j;
import net.wanji.com.netty.NettyClient;
import net.wanji.com.pojo.netty.MessageResultPojo;
import net.wanji.com.service.protocol.ProtocolConversion;
import net.wanji.databus.po.CrossInfoPO;
import org.springframework.stereotype.Service;
/**
* @author duanruiming
* @date 2023/05/16 17:16
*/
@Service
@Slf4j
public class SignalDeviceProtocolConversionService implements ProtocolConversion {
@Override
public Object protocolConvertEntity(CrossInfoPO crossInfo) {
MessageResultPojo resultPojo = NettyClient.sendMsg("10.102.1.204", 5050, "0x7e00120001010000000101011001000501030000005CB40x7d", "20", 300);
log.info("设备基本信息: {}", resultPojo);
return null;
}
@Override
public String entityConvertProtocol(Object o) {
return null;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment