Browse Source

PatrolDevice和PatrolHost转换

master
lijw 9 months ago
parent
commit
4ec070f494
1 changed files with 14 additions and 0 deletions
  1. +14
    -0
      src/main/java/com/inspect/tcpserver/tcp/NettyServer.java

+ 14
- 0
src/main/java/com/inspect/tcpserver/tcp/NettyServer.java View File

@ -150,6 +150,13 @@ public class NettyServer {
//发送消息
public void flushMsgToDevice(String uuid, String clientKey, boolean request, String xml) {
if (tcpClientMap.containsKey(clientKey)) {
if(clientKey.startsWith("areaPatrolServer")) {
xml = xml.replace("<PatrolDevice>", "<PatrolHost>");
xml = xml.replace("</PatrolDevice>", "</PatrolHost>");
} else {
xml = xml.replace("<PatrolHost>", "<PatrolDevice>");
xml = xml.replace("</PatrolHost>", "</PatrolDevice>");
}
ByteBuf byteBuf = Unpooled.copiedBuffer(xml, CharsetUtil.UTF_8);
int length = byteBuf.readableBytes();
ByteBuf allBuf = Unpooled.buffer(length + ConfigType.dataLength);
@ -173,6 +180,13 @@ public class NettyServer {
public void flushMsgToDeviceBroadcast(String uuid, String clientKey, boolean request, String xml) {
for (Map.Entry<String, String> entry : tcpClientMap.entrySet()) {
if(clientKey.startsWith("areaPatrolServer")) {
xml = xml.replace("<PatrolDevice>", "<PatrolHost>");
xml = xml.replace("</PatrolDevice>", "</PatrolHost>");
} else {
xml = xml.replace("<PatrolHost>", "<PatrolDevice>");
xml = xml.replace("</PatrolHost>", "</PatrolDevice>");
}
ByteBuf byteBuf = Unpooled.copiedBuffer(xml, CharsetUtil.UTF_8);
int length = byteBuf.readableBytes();
ByteBuf allBuf = Unpooled.buffer(length + ConfigType.dataLength);


Loading…
Cancel
Save