修复消息超时未回复误报

This commit is contained in:
648540858
2024-10-19 20:27:42 +08:00
parent a548dec2c2
commit 91e671ec4b
4 changed files with 21 additions and 11 deletions

View File

@@ -97,10 +97,12 @@ public class SIPProcessorObserver implements ISIPProcessorObserver {
CallIdHeader callIdHeader = response.getCallIdHeader();
if (callIdHeader != null) {
SipEvent sipEvent = sipSubscribe.getSubscribe(callIdHeader.getCallId());
if (sipEvent != null && sipEvent.getOkEvent() != null) {
SipSubscribe.EventResult<ResponseEvent> eventResult = new SipSubscribe.EventResult<>(responseEvent);
if (sipEvent != null) {
if (sipEvent.getOkEvent() != null) {
SipSubscribe.EventResult<ResponseEvent> eventResult = new SipSubscribe.EventResult<>(responseEvent);
sipEvent.getOkEvent().response(eventResult);
}
sipSubscribe.removeSubscribe(callIdHeader.getCallId());
sipEvent.getOkEvent().response(eventResult);
}
}
}
@@ -118,10 +120,12 @@ public class SIPProcessorObserver implements ISIPProcessorObserver {
CallIdHeader callIdHeader = (CallIdHeader)responseEvent.getResponse().getHeader(CallIdHeader.NAME);
if (callIdHeader != null) {
SipEvent sipEvent = sipSubscribe.getSubscribe(callIdHeader.getCallId());
if (sipEvent != null && sipEvent.getErrorEvent() != null) {
SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(responseEvent);
if (sipEvent != null ) {
if (sipEvent.getErrorEvent() != null) {
SipSubscribe.EventResult<ResponseEvent> eventResult = new SipSubscribe.EventResult<>(responseEvent);
sipEvent.getErrorEvent().response(eventResult);
}
sipSubscribe.removeSubscribe(callIdHeader.getCallId());
sipEvent.getErrorEvent().response(eventResult);
}
}
}

View File

@@ -72,17 +72,18 @@ public class SIPSender {
if (okEvent != null || errorEvent != null) {
CallIdHeader callIdHeader = (CallIdHeader) message.getHeader(CallIdHeader.NAME);
SipEvent sipEvent = SipEvent.getInstance(callIdHeader.getCallId(), eventResult -> {
sipSubscribe.removeSubscribe(eventResult.callId);
sipSubscribe.removeSubscribe(callIdHeader.getCallId());
if(okEvent != null) {
okEvent.response(eventResult);
}
}, (eventResult -> {
sipSubscribe.removeSubscribe(eventResult.callId);
sipSubscribe.removeSubscribe(callIdHeader.getCallId());
if (errorEvent != null) {
errorEvent.response(eventResult);
}
}), timeout == null ? sipConfig.getTimeout() : timeout);
sipSubscribe.addSubscribe(callIdHeader.getCallId(), sipEvent);
System.out.println("订阅数量" + sipSubscribe.size());
}
if ("TCP".equals(transport)) {