mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
阻止重复帧
This commit is contained in:
@@ -22,6 +22,8 @@ public abstract class AbstractYkcHandler implements InitializingBean {
|
||||
@Autowired
|
||||
private RedisCache redisCache;
|
||||
|
||||
private static final String REQUEST_PREFIX = "Request_";
|
||||
|
||||
/**
|
||||
* 执行逻辑
|
||||
* 有应答
|
||||
@@ -96,7 +98,7 @@ public abstract class AbstractYkcHandler implements InitializingBean {
|
||||
String frameTypeStr = YKCUtils.frameType2Str(ykcDataProtocol.getFrameType());
|
||||
// 获取channelId
|
||||
String channelId = ctx.channel().id().asShortText();
|
||||
String redisKey = "Request_" + channelId + "_" + frameTypeStr;
|
||||
String redisKey = REQUEST_PREFIX + channelId + "_" + frameTypeStr;
|
||||
Boolean result = redisCache.setnx(redisKey, ykcDataProtocol.getHEXString(), 30);
|
||||
// result返回false说明没有设置成功,就是说已经有相同请求了,所以返回true重复
|
||||
return !result;
|
||||
|
||||
Reference in New Issue
Block a user