| | |
| | | import com.genersoft.iot.vmp.utils.SerializeUtils; |
| | | import gov.nist.javax.sip.SipProviderImpl; |
| | | import gov.nist.javax.sip.SipStackImpl; |
| | | import gov.nist.javax.sip.message.MessageFactoryImpl; |
| | | import gov.nist.javax.sip.message.SIPRequest; |
| | | import gov.nist.javax.sip.stack.SIPDialog; |
| | | import org.slf4j.Logger; |
| | |
| | | @Override |
| | | public boolean unregister(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) { |
| | | ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); |
| | | parentPlatform.setExpires("0"); |
| | | if (parentPlatformCatch != null) { |
| | | parentPlatformCatch.setParentPlatform(parentPlatform); |
| | | redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); |
| | | } |
| | | parentPlatform.setExpires("0"); |
| | | return register(parentPlatform, null, null, errorEvent, okEvent, false); |
| | | } |
| | | |
| | |
| | | private void sendNotify(ParentPlatform parentPlatform, String catalogXmlContent, |
| | | SubscribeInfo subscribeInfo, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent ) |
| | | throws NoSuchFieldException, IllegalAccessException, SipException, ParseException { |
| | | MessageFactoryImpl messageFactory = (MessageFactoryImpl) sipFactory.createMessageFactory(); |
| | | // 设置编码, 防止中文乱码 |
| | | messageFactory.setDefaultContentEncodingCharset("gb2312"); |
| | | Dialog dialog = subscribeInfo.getDialog(); |
| | | Request notifyRequest = dialog.createRequest(Request.NOTIFY); |
| | | |
| | | if (dialog == null) return; |
| | | SIPRequest notifyRequest = (SIPRequest)dialog.createRequest(Request.NOTIFY); |
| | | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); |
| | | |
| | | notifyRequest.setContent(catalogXmlContent, contentTypeHeader); |
| | | |
| | | SubscriptionStateHeader subscriptionState = sipFactory.createHeaderFactory() |
| | |
| | | } |
| | | |
| | | @Override |
| | | public boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo, Integer index) { |
| | | public boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, |
| | | SubscribeInfo subscribeInfo, Integer index) { |
| | | if (parentPlatform == null |
| | | || deviceChannels == null |
| | | || deviceChannels.size() == 0 |
| | |
| | | recordXml.append("<SN>" +recordInfo.getSn() + "</SN>\r\n"); |
| | | recordXml.append("<DeviceID>" + recordInfo.getDeviceId() + "</DeviceID>\r\n"); |
| | | recordXml.append("<SumNum>" + recordInfo.getSumNum() + "</SumNum>\r\n"); |
| | | if (recordInfo.getRecordList() == null ) { |
| | | recordXml.append("<RecordList Num=\"0\">\r\n"); |
| | | }else { |
| | | recordXml.append("<RecordList Num=\"" + recordInfo.getRecordList().size()+"\">\r\n"); |
| | | if (recordInfo.getRecordList().size() > 0) { |
| | | for (RecordItem recordItem : recordInfo.getRecordList()) { |
| | | recordXml.append("<Item>\r\n"); |
| | | if (deviceChannel != null) { |
| | |
| | | } |
| | | recordXml.append("</Item>\r\n"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | recordXml.append("</RecordList>\r\n"); |
| | | recordXml.append("</Response>\r\n"); |