Commit 3609d361118d75dd221959977bfac33a37815953
1 parent
95889f35
完成响应上级远程启动信令执行
Showing
1 changed file
with
20 additions
and
2 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
| ... | ... | @@ -7,8 +7,11 @@ import java.util.*; |
| 7 | 7 | import javax.sip.header.FromHeader; |
| 8 | 8 | import javax.sip.header.HeaderAddress; |
| 9 | 9 | import javax.sip.InvalidArgumentException; |
| 10 | +import javax.sip.ListeningPoint; | |
| 11 | +import javax.sip.ObjectInUseException; | |
| 10 | 12 | import javax.sip.RequestEvent; |
| 11 | 13 | import javax.sip.SipException; |
| 14 | +import javax.sip.SipProvider; | |
| 12 | 15 | import javax.sip.message.Request; |
| 13 | 16 | import javax.sip.message.Response; |
| 14 | 17 | |
| ... | ... | @@ -36,6 +39,7 @@ import com.genersoft.iot.vmp.utils.SpringBeanFactory; |
| 36 | 39 | import com.genersoft.iot.vmp.utils.redis.RedisUtil; |
| 37 | 40 | import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce; |
| 38 | 41 | |
| 42 | +import gov.nist.javax.sip.SipStackImpl; | |
| 39 | 43 | import gov.nist.javax.sip.address.AddressImpl; |
| 40 | 44 | import gov.nist.javax.sip.address.SipUri; |
| 41 | 45 | |
| ... | ... | @@ -286,7 +290,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { |
| 286 | 290 | deferredResultHolder.invokeResult(msg); |
| 287 | 291 | } else { |
| 288 | 292 | // 此处是上级发出的DeviceControl指令 |
| 289 | - if (XmlUtil.getText(rootElement, "TeleBoot").equals("Boot") && false) { // 远程启动功能:需要在重新启动程序后先对SipStack解绑 | |
| 293 | + if (XmlUtil.getText(rootElement, "TeleBoot").equals("Boot") ) { // 远程启动功能:需要在重新启动程序后先对SipStack解绑 | |
| 290 | 294 | String platformId = ((SipUri) ((HeaderAddress) evt.getRequest().getHeader(FromHeader.NAME)).getAddress().getURI()).getUser(); |
| 291 | 295 | logger.info("执行远程启动命令"); |
| 292 | 296 | ParentPlatform parentPlatform = storager.queryParentPlatById(platformId); |
| ... | ... | @@ -296,12 +300,26 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { |
| 296 | 300 | @Override |
| 297 | 301 | public void run() { |
| 298 | 302 | try { |
| 299 | - Thread.sleep(1000); | |
| 303 | + Thread.sleep(3000); | |
| 304 | + SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider"); | |
| 305 | + SipStackImpl stack = (SipStackImpl)up.getSipStack(); | |
| 306 | + stack.stop(); | |
| 307 | + Iterator listener = stack.getListeningPoints(); | |
| 308 | + while (listener.hasNext()) { | |
| 309 | + stack.deleteListeningPoint((ListeningPoint) listener.next()); | |
| 310 | + } | |
| 311 | + Iterator providers = stack.getSipProviders(); | |
| 312 | + while (providers.hasNext()) { | |
| 313 | + stack.deleteSipProvider((SipProvider) providers.next()); | |
| 314 | + } | |
| 300 | 315 | VManageBootstrap.restart(); |
| 301 | 316 | } catch (InterruptedException ignored) { |
| 317 | + } catch (ObjectInUseException e) { | |
| 318 | + e.printStackTrace(); | |
| 302 | 319 | } |
| 303 | 320 | } |
| 304 | 321 | }); |
| 322 | + | |
| 305 | 323 | restartThread.setDaemon(false); |
| 306 | 324 | restartThread.start(); |
| 307 | 325 | } | ... | ... |