Commit 9e6e897fc334cd2ae7650d146ceda4870e92f1ad

Authored by xp.Huang
1 parent 6813f309

fix: 修改设备凭证和删除设备时移除设备会话信息

... ... @@ -17,6 +17,7 @@ import java.security.NoSuchAlgorithmException;
17 17 import java.text.ParseException;
18 18 import java.util.*;
19 19 import java.util.concurrent.ConcurrentHashMap;
  20 +import java.util.stream.Collectors;
20 21 import javax.annotation.PostConstruct;
21 22 import javax.sdp.SdpFactory;
22 23 import javax.sdp.SdpParseException;
... ... @@ -769,9 +770,11 @@ public class SIPProcessorObserver extends SIPRequestProcessorParent
769 770 UUID sessionId, TransportProtos.SessionCloseNotificationProto sessionCloseNotification) {
770 771 log.trace(
771 772 "[{}] Received the remote command to close the session: {}",
772   - sessionId,
  773 + sessionId,
773 774 sessionCloseNotification.getMessage());
774   - // deviceSessionCtx.getChannel().close();
  775 + List<String> cameraCodes = deviceSessions.values().stream().filter(gbtDeviceSessionCtx ->gbtDeviceSessionCtx.getSessionId().equals(sessionId))
  776 + .map(gbtDeviceSessionCtx -> gbtDeviceSessionCtx.getCameraCode()).collect(Collectors.toList());
  777 + removeDeviceSession(cameraCodes);
775 778 }
776 779
777 780 @Override
... ... @@ -963,11 +966,16 @@ public class SIPProcessorObserver extends SIPRequestProcessorParent
963 966
964 967 @Override
965 968 public void onDeviceDeleted(DeviceId deviceId) {
966   - // context.onAuthFailure(address);
967   - // ChannelHandlerContext ctx = deviceSessionCtx.getChannel();
968   - // ctx.close();
  969 + List<String> cameraCodes = deviceSessions.values().stream().filter(gbtDeviceSessionCtx -> gbtDeviceSessionCtx.getDeviceId().equals(deviceId))
  970 + .map(gbtDeviceSessionCtx->gbtDeviceSessionCtx.getCameraCode()).collect(Collectors.toList());
  971 + removeDeviceSession(cameraCodes);
969 972 }
970 973
  974 + private void removeDeviceSession(List<String> cameraCodes){
  975 + if(null != cameraCodes && !cameraCodes.isEmpty()){
  976 + deviceSessions.remove(cameraCodes.get(0));
  977 + }
  978 + }
971 979 public void cameraInviteResponse(ResponseEvent evt) {
972 980
973 981 try {
... ...