|
@@ -26,6 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.*;
|
|
import java.util.concurrent.*;
|
|
@@ -39,6 +40,9 @@ public class NettyServerHandler implements ChannelInboundHandler {
|
|
|
|
|
|
|
|
private BeaconMate beaconMate = new BeaconMateImpl();
|
|
private BeaconMate beaconMate = new BeaconMateImpl();
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ private static Map<String,Object> map =new HashMap <>();
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 读取客户端发送的消息
|
|
* 读取客户端发送的消息
|
|
|
*/
|
|
*/
|
|
@@ -48,6 +52,7 @@ public class NettyServerHandler implements ChannelInboundHandler {
|
|
|
String data = TCPServer.bytesToHexString(msg).toUpperCase();
|
|
String data = TCPServer.bytesToHexString(msg).toUpperCase();
|
|
|
String dataStr=TCPServer.hexStr2Str(data);
|
|
String dataStr=TCPServer.hexStr2Str(data);
|
|
|
log.info("**************************************"+dataStr+"****************************************");
|
|
log.info("**************************************"+dataStr+"****************************************");
|
|
|
|
|
+
|
|
|
if(data.startsWith(SocketTypes.RELAY_PREFIX.replaceAll(" ", "").toUpperCase())){
|
|
if(data.startsWith(SocketTypes.RELAY_PREFIX.replaceAll(" ", "").toUpperCase())){
|
|
|
|
|
|
|
|
analyticRelayData(data, channelHandlerContext);
|
|
analyticRelayData(data, channelHandlerContext);
|
|
@@ -87,6 +92,15 @@ public class NettyServerHandler implements ChannelInboundHandler {
|
|
|
RelayUtils.relayOpenClose(dataStr,relayCode);
|
|
RelayUtils.relayOpenClose(dataStr,relayCode);
|
|
|
}else if(JsonUtils.isJsonString(dataStr)){
|
|
}else if(JsonUtils.isJsonString(dataStr)){
|
|
|
beaconMate.sendBeaconMate(dataStr);
|
|
beaconMate.sendBeaconMate(dataStr);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ if(dataStr.indexOf("{")>0 && dataStr.lastIndexOf("}")==-1){
|
|
|
|
|
+ ChannelMapJson.getChannelMap().put(channelHandlerContext,dataStr);
|
|
|
|
|
+ }else if(dataStr.indexOf("{")==-1 && dataStr.lastIndexOf("}")>0){
|
|
|
|
|
+ if(ChannelMapJson.getChannelMap().get(channelHandlerContext)!=null){
|
|
|
|
|
+ String newDataStr = ChannelMapJson.getChannelMap().get(channelHandlerContext)+dataStr;
|
|
|
|
|
+ beaconMate.sendBeaconMate(newDataStr);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|