|  | @@ -7,6 +7,9 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.timeout.ITimeoutProcessor;
 | 
	
		
			
				|  |  |  import org.slf4j.Logger;
 | 
	
		
			
				|  |  |  import org.slf4j.LoggerFactory;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | +import org.springframework.beans.factory.annotation.Qualifier;
 | 
	
		
			
				|  |  | +import org.springframework.scheduling.annotation.Async;
 | 
	
		
			
				|  |  | +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Component;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import javax.sip.*;
 | 
	
	
		
			
				|  | @@ -22,7 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
 | 
	
		
			
				|  |  |   * @date:   2021年11月5日 下午15:32
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  @Component
 | 
	
		
			
				|  |  | -public class SIPProcessorObserver implements SipListener {
 | 
	
		
			
				|  |  | +public class SIPProcessorObserver implements ISIPProcessorObserver {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private final static Logger logger = LoggerFactory.getLogger(SIPProcessorObserver.class);
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -33,6 +36,10 @@ public class SIPProcessorObserver implements SipListener {
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private SipSubscribe sipSubscribe;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    @Qualifier(value = "taskExecutor")
 | 
	
		
			
				|  |  | +    private ThreadPoolTaskExecutor poolTaskExecutor;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 添加 request订阅
 | 
	
		
			
				|  |  |       * @param method 方法名
 | 
	
	
		
			
				|  | @@ -65,13 +72,17 @@ public class SIPProcessorObserver implements SipListener {
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void processRequest(RequestEvent requestEvent) {
 | 
	
		
			
				|  |  | -        String method = requestEvent.getRequest().getMethod();
 | 
	
		
			
				|  |  | -        ISIPRequestProcessor sipRequestProcessor = requestProcessorMap.get(method);
 | 
	
		
			
				|  |  | -        if (sipRequestProcessor == null) {
 | 
	
		
			
				|  |  | -            logger.warn("不支持方法{}的request", method);
 | 
	
		
			
				|  |  | -            return;
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        requestProcessorMap.get(method).process(requestEvent);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        poolTaskExecutor.execute(() -> {
 | 
	
		
			
				|  |  | +            String method = requestEvent.getRequest().getMethod();
 | 
	
		
			
				|  |  | +            ISIPRequestProcessor sipRequestProcessor = requestProcessorMap.get(method);
 | 
	
		
			
				|  |  | +            if (sipRequestProcessor == null) {
 | 
	
		
			
				|  |  | +                logger.warn("不支持方法{}的request", method);
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            requestProcessorMap.get(method).process(requestEvent);
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
	
		
			
				|  | @@ -90,43 +101,45 @@ public class SIPProcessorObserver implements SipListener {
 | 
	
		
			
				|  |  |  //        }
 | 
	
		
			
				|  |  |  //        sipRequestProcessor.process(responseEvent);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        Response response = responseEvent.getResponse();
 | 
	
		
			
				|  |  | -        logger.debug(responseEvent.getResponse().toString());
 | 
	
		
			
				|  |  | -        int status = response.getStatusCode();
 | 
	
		
			
				|  |  | -        if (((status >= 200) && (status < 300)) || status == 401) { // Success!
 | 
	
		
			
				|  |  | +        poolTaskExecutor.execute(() -> {
 | 
	
		
			
				|  |  | +            Response response = responseEvent.getResponse();
 | 
	
		
			
				|  |  | +            logger.debug(responseEvent.getResponse().toString());
 | 
	
		
			
				|  |  | +            int status = response.getStatusCode();
 | 
	
		
			
				|  |  | +            if (((status >= 200) && (status < 300)) || status == 401) { // Success!
 | 
	
		
			
				|  |  |  //            ISIPResponseProcessor processor = processorFactory.createResponseProcessor(evt);
 | 
	
		
			
				|  |  | -            CSeqHeader cseqHeader = (CSeqHeader) responseEvent.getResponse().getHeader(CSeqHeader.NAME);
 | 
	
		
			
				|  |  | -            String method = cseqHeader.getMethod();
 | 
	
		
			
				|  |  | -            ISIPResponseProcessor sipRequestProcessor = responseProcessorMap.get(method);
 | 
	
		
			
				|  |  | -            if (sipRequestProcessor != null) {
 | 
	
		
			
				|  |  | -                sipRequestProcessor.process(responseEvent);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -            if (responseEvent.getResponse() != null && sipSubscribe.getOkSubscribesSize() > 0 ) {
 | 
	
		
			
				|  |  | -                CallIdHeader callIdHeader = (CallIdHeader)responseEvent.getResponse().getHeader(CallIdHeader.NAME);
 | 
	
		
			
				|  |  | -                if (callIdHeader != null) {
 | 
	
		
			
				|  |  | -                    SipSubscribe.Event subscribe = sipSubscribe.getOkSubscribe(callIdHeader.getCallId());
 | 
	
		
			
				|  |  | -                    if (subscribe != null) {
 | 
	
		
			
				|  |  | -                        SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(responseEvent);
 | 
	
		
			
				|  |  | -                        subscribe.response(eventResult);
 | 
	
		
			
				|  |  | +                CSeqHeader cseqHeader = (CSeqHeader) responseEvent.getResponse().getHeader(CSeqHeader.NAME);
 | 
	
		
			
				|  |  | +                String method = cseqHeader.getMethod();
 | 
	
		
			
				|  |  | +                ISIPResponseProcessor sipRequestProcessor = responseProcessorMap.get(method);
 | 
	
		
			
				|  |  | +                if (sipRequestProcessor != null) {
 | 
	
		
			
				|  |  | +                    sipRequestProcessor.process(responseEvent);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +                if (responseEvent.getResponse() != null && sipSubscribe.getOkSubscribesSize() > 0 ) {
 | 
	
		
			
				|  |  | +                    CallIdHeader callIdHeader = (CallIdHeader)responseEvent.getResponse().getHeader(CallIdHeader.NAME);
 | 
	
		
			
				|  |  | +                    if (callIdHeader != null) {
 | 
	
		
			
				|  |  | +                        SipSubscribe.Event subscribe = sipSubscribe.getOkSubscribe(callIdHeader.getCallId());
 | 
	
		
			
				|  |  | +                        if (subscribe != null) {
 | 
	
		
			
				|  |  | +                            SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(responseEvent);
 | 
	
		
			
				|  |  | +                            subscribe.response(eventResult);
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | -        } else if ((status >= 100) && (status < 200)) {
 | 
	
		
			
				|  |  | -            // 增加其它无需回复的响应,如101、180等
 | 
	
		
			
				|  |  | -        } else {
 | 
	
		
			
				|  |  | -            logger.warn("接收到失败的response响应!status:" + status + ",message:" + response.getReasonPhrase()/* .getContent().toString()*/);
 | 
	
		
			
				|  |  | -            if (responseEvent.getResponse() != null && sipSubscribe.getErrorSubscribesSize() > 0 ) {
 | 
	
		
			
				|  |  | -                CallIdHeader callIdHeader = (CallIdHeader)responseEvent.getResponse().getHeader(CallIdHeader.NAME);
 | 
	
		
			
				|  |  | -                if (callIdHeader != null) {
 | 
	
		
			
				|  |  | -                    SipSubscribe.Event subscribe = sipSubscribe.getErrorSubscribe(callIdHeader.getCallId());
 | 
	
		
			
				|  |  | -                    if (subscribe != null) {
 | 
	
		
			
				|  |  | -                        SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(responseEvent);
 | 
	
		
			
				|  |  | -                        subscribe.response(eventResult);
 | 
	
		
			
				|  |  | +            } else if ((status >= 100) && (status < 200)) {
 | 
	
		
			
				|  |  | +                // 增加其它无需回复的响应,如101、180等
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                logger.warn("接收到失败的response响应!status:" + status + ",message:" + response.getReasonPhrase()/* .getContent().toString()*/);
 | 
	
		
			
				|  |  | +                if (responseEvent.getResponse() != null && sipSubscribe.getErrorSubscribesSize() > 0 ) {
 | 
	
		
			
				|  |  | +                    CallIdHeader callIdHeader = (CallIdHeader)responseEvent.getResponse().getHeader(CallIdHeader.NAME);
 | 
	
		
			
				|  |  | +                    if (callIdHeader != null) {
 | 
	
		
			
				|  |  | +                        SipSubscribe.Event subscribe = sipSubscribe.getErrorSubscribe(callIdHeader.getCallId());
 | 
	
		
			
				|  |  | +                        if (subscribe != null) {
 | 
	
		
			
				|  |  | +                            SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(responseEvent);
 | 
	
		
			
				|  |  | +                            subscribe.response(eventResult);
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 |