From c2ef001546ff304f997c0162e71edd0d7e0e228a Mon Sep 17 00:00:00 2001 From: fine <54142345+criver31@users.noreply.github.com> Date: 星期三, 31 五月 2023 09:35:08 +0800 Subject: [PATCH] Update MobilePositionResponseMessageHandler.java --- src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java | 34 +++++++++++++++++++--------------- 1 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java index 3d5c294..83722a0 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java @@ -1,6 +1,5 @@ package com.genersoft.iot.vmp.gb28181.transmit.callback; -import com.alibaba.fastjson2.JSON; import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx; import org.springframework.stereotype.Component; import org.springframework.util.ObjectUtils; @@ -51,6 +50,8 @@ public static final String CALLBACK_CMD_ALARM = "CALLBACK_ALARM"; public static final String CALLBACK_CMD_BROADCAST = "CALLBACK_BROADCAST"; + + public static final String CALLBACK_CMD_SNAP= "CALLBACK_SNAP"; private Map<String, Map<String, DeferredResultEx>> map = new ConcurrentHashMap<>(); @@ -130,23 +131,26 @@ if (deferredResultMap == null) { return; } - Set<String> ids = deferredResultMap.keySet(); - for (String id : ids) { - DeferredResultEx result = deferredResultMap.get(id); - if (result == null) { + synchronized (this) { + deferredResultMap = map.get(msg.getKey()); + if (deferredResultMap == null) { return; } - if (result.getFilter() != null) { - Object handler = result.getFilter().handler(msg.getData()); - System.out.println(JSON.toJSONString(handler)); - result.getDeferredResult().setResult(handler); - }else { - result.getDeferredResult().setResult(msg.getData()); + Set<String> ids = deferredResultMap.keySet(); + for (String id : ids) { + DeferredResultEx result = deferredResultMap.get(id); + if (result == null) { + return; + } + if (result.getFilter() != null) { + Object handler = result.getFilter().handler(msg.getData()); + result.getDeferredResult().setResult(handler); + }else { + result.getDeferredResult().setResult(msg.getData()); + } + } - + map.remove(msg.getKey()); } - map.remove(msg.getKey()); } - - } -- Gitblit v1.8.0