| | |
| | | Element rootElement = getRootElement(evt); |
| | | String cmd = XmlUtil.getText(rootElement, "CmdType"); |
| | | if (CmdType.MOBILE_POSITION.equals(cmd)) { |
| | | logger.info("接收到MobilePosition订阅"); |
| | | processNotifyMobilePosition(evt, rootElement); |
| | | // } else if (CmdType.ALARM.equals(cmd)) { |
| | | // logger.info("接收到Alarm订阅"); |
| | | // processNotifyAlarm(evt, rootElement); |
| | | // } else if (CmdType.CATALOG.equals(cmd)) { |
| | | // logger.info("接收到Catalog订阅"); |
| | | // processNotifyCatalogList(evt, rootElement); |
| | | } else if (CmdType.CATALOG.equals(cmd)) { |
| | | processNotifyCatalogList(evt, rootElement); |
| | | } else { |
| | | logger.info("接收到消息:" + cmd); |
| | | // responseAck(evt, Response.OK); |
| | | |
| | | Response response = null; |
| | | response = getMessageFactory().createResponse(200, request); |
| | |
| | | SubscribeInfo subscribeInfo = new SubscribeInfo(evt, platformId); |
| | | String sn = XmlUtil.getText(rootElement, "SN"); |
| | | String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_MobilePosition_" + platformId; |
| | | |
| | | logger.info("接收到{}的MobilePosition订阅", platformId); |
| | | StringBuilder resultXml = new StringBuilder(200); |
| | | resultXml.append("<?xml version=\"1.0\" ?>\r\n") |
| | | .append("<Response>\r\n") |
| | |
| | | } |
| | | |
| | | private void processNotifyCatalogList(RequestEvent evt, Element rootElement) { |
| | | String platformId = SipUtils.getUserIdFromFromHeader(evt.getRequest()); |
| | | String deviceID = XmlUtil.getText(rootElement, "DeviceID"); |
| | | SubscribeInfo subscribeInfo = new SubscribeInfo(evt, platformId); |
| | | String sn = XmlUtil.getText(rootElement, "SN"); |
| | | String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_" + platformId; |
| | | logger.info("接收到{}的Catalog订阅", platformId); |
| | | StringBuilder resultXml = new StringBuilder(200); |
| | | resultXml.append("<?xml version=\"1.0\" ?>\r\n") |
| | | .append("<Response>\r\n") |
| | | .append("<CmdType>Catalog</CmdType>\r\n") |
| | | .append("<SN>" + sn + "</SN>\r\n") |
| | | .append("<DeviceID>" + deviceID + "</DeviceID>\r\n") |
| | | .append("<Result>OK</Result>\r\n") |
| | | .append("</Response>\r\n"); |
| | | |
| | | if (subscribeInfo.getExpires() > 0) { |
| | | redisCatchStorage.updateSubscribe(key, subscribeInfo); |
| | | }else if (subscribeInfo.getExpires() == 0) { |
| | | redisCatchStorage.delSubscribe(key); |
| | | } |
| | | |
| | | try { |
| | | Response response = responseXmlAck(evt, resultXml.toString()); |
| | | ToHeader toHeader = (ToHeader)response.getHeader(ToHeader.NAME); |
| | | subscribeInfo.setToTag(toHeader.getTag()); |
| | | redisCatchStorage.updateSubscribe(key, subscribeInfo); |
| | | |
| | | } catch (SipException e) { |
| | | e.printStackTrace(); |
| | | } catch (InvalidArgumentException e) { |
| | | e.printStackTrace(); |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | } |