对未注册的连接和消息进行无情抛弃
This commit is contained in:
parent
18e4f0a99d
commit
fc568b6542
@ -63,10 +63,10 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
|
|||||||
public void handleBinary(ClientHandler handler, byte[] data) throws IOException {
|
public void handleBinary(ClientHandler handler, byte[] data) throws IOException {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
String pileNo = ChargingPileServer.getPileNo(handler);
|
||||||
List<byte[]> dataList = parseDataList(data);
|
List<byte[]> dataList = parseDataList(data);
|
||||||
for (byte[] d : dataList) {
|
for (byte[] d : dataList) {
|
||||||
String dataStr = toHex(d);
|
String dataStr = toHex(d);
|
||||||
String pileNo = ChargingPileServer.getPileNo(handler);
|
|
||||||
log.debug("received data <<<< |{}| from pile <- ({})", dataStr, pileNo);
|
log.debug("received data <<<< |{}| from pile <- ({})", dataStr, pileNo);
|
||||||
if (d.length <= 2 || !dataStr.startsWith("68")) {
|
if (d.length <= 2 || !dataStr.startsWith("68")) {
|
||||||
log.debug("received invalid data <<<< |{}|, len[{}]", dataStr, d.length);
|
log.debug("received invalid data <<<< |{}|, len[{}]", dataStr, d.length);
|
||||||
@ -88,7 +88,8 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void process(ClientHandler handler, byte[] data) throws TxException, IOException, NacosException, InterruptedException {
|
private void process(ClientHandler handler, byte[] data) throws TxException, IOException, NacosException,
|
||||||
|
InterruptedException {
|
||||||
|
|
||||||
String serviceName = toHex(data, 5, 6);
|
String serviceName = toHex(data, 5, 6);
|
||||||
String version = ChargingPileServer.getVersion(handler.getName());
|
String version = ChargingPileServer.getVersion(handler.getName());
|
||||||
@ -105,8 +106,7 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
|
|||||||
cachePile.put("tcfg", false);
|
cachePile.put("tcfg", false);
|
||||||
REDIS.setCacheMap(pilekey, cachePile);
|
REDIS.setCacheMap(pilekey, cachePile);
|
||||||
regHandler(handler, pileNo, req);
|
regHandler(handler, pileNo, req);
|
||||||
}
|
} else if (SERVICE_RMR.equals(serviceName) && OK.equals(resultCode)) {
|
||||||
if (SERVICE_RMR.equals(serviceName) && OK.equals(resultCode)) {
|
|
||||||
setCachePileRM(pilekey);
|
setCachePileRM(pilekey);
|
||||||
}
|
}
|
||||||
if (result.getBinary() != null) {
|
if (result.getBinary() != null) {
|
||||||
@ -130,6 +130,10 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
|
|||||||
xhpcDeviceMessageMapper.insertByDomain(deviceMessage);
|
xhpcDeviceMessageMapper.insertByDomain(deviceMessage);
|
||||||
}
|
}
|
||||||
if (SERVICE_HB.equals(serviceName) && OK.equals(resultCode)) {
|
if (SERVICE_HB.equals(serviceName) && OK.equals(resultCode)) {
|
||||||
|
pileNo = ChargingPileServer.getPileNo(handler);
|
||||||
|
if (null == pileNo) {
|
||||||
|
handler.forceClose();
|
||||||
|
} else {
|
||||||
Boolean tcfg = (Boolean) cachePile.get("tcfg");
|
Boolean tcfg = (Boolean) cachePile.get("tcfg");
|
||||||
if (tcfg == null || !tcfg) {
|
if (tcfg == null || !tcfg) {
|
||||||
String skey = pilekey.concat(".seqhex");
|
String skey = pilekey.concat(".seqhex");
|
||||||
@ -154,6 +158,7 @@ public class ChargingPileBinaryHandler implements ClientBinaryHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String getTimeBin(String seqhex, String pileNo, Date date) {
|
private String getTimeBin(String seqhex, String pileNo, Date date) {
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user