修复设备在事务内注销失败的问题

pull/1270/head
648540858 2024-01-18 10:17:03 +08:00
parent 88721511e7
commit 7f79b92568
1 changed files with 20 additions and 16 deletions

View File

@ -103,23 +103,27 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
String title = registerFlag ? "[注册请求]": "[注销请求]"; String title = registerFlag ? "[注册请求]": "[注销请求]";
logger.info(title + "设备:{}, 开始处理: {}", deviceId, requestAddress); logger.info(title + "设备:{}, 开始处理: {}", deviceId, requestAddress);
if (device != null && if (device != null &&
device.getSipTransactionInfo() != null && device.getSipTransactionInfo() != null &&
request.getCallIdHeader().getCallId().equals(device.getSipTransactionInfo().getCallId())) { request.getCallIdHeader().getCallId().equals(device.getSipTransactionInfo().getCallId())) {
logger.info(title + "设备:{}, 注册续订: {}",device.getDeviceId(), device.getDeviceId()); logger.info(title + "设备:{}, 注册续订: {}",device.getDeviceId(), device.getDeviceId());
device.setExpires(request.getExpires().getExpires()); if (registerFlag) {
device.setIp(remoteAddressInfo.getIp()); device.setExpires(request.getExpires().getExpires());
device.setPort(remoteAddressInfo.getPort()); device.setIp(remoteAddressInfo.getIp());
device.setHostAddress(remoteAddressInfo.getIp().concat(":").concat(String.valueOf(remoteAddressInfo.getPort()))); device.setPort(remoteAddressInfo.getPort());
device.setLocalIp(request.getLocalAddress().getHostAddress()); device.setHostAddress(remoteAddressInfo.getIp().concat(":").concat(String.valueOf(remoteAddressInfo.getPort())));
Response registerOkResponse = getRegisterOkResponse(request); device.setLocalIp(request.getLocalAddress().getHostAddress());
// 判断TCP还是UDP Response registerOkResponse = getRegisterOkResponse(request);
ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME); // 判断TCP还是UDP
String transport = reqViaHeader.getTransport(); ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME);
device.setTransport("TCP".equalsIgnoreCase(transport) ? "TCP" : "UDP"); String transport = reqViaHeader.getTransport();
sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), registerOkResponse); device.setTransport("TCP".equalsIgnoreCase(transport) ? "TCP" : "UDP");
device.setRegisterTime(DateUtil.getNow()); sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), registerOkResponse);
SipTransactionInfo sipTransactionInfo = new SipTransactionInfo((SIPResponse)registerOkResponse); device.setRegisterTime(DateUtil.getNow());
deviceService.online(device, sipTransactionInfo); SipTransactionInfo sipTransactionInfo = new SipTransactionInfo((SIPResponse)registerOkResponse);
deviceService.online(device, sipTransactionInfo);
}else {
deviceService.offline(deviceId, "主动注销");
}
return; return;
} }
String password = (device != null && !ObjectUtils.isEmpty(device.getPassword()))? device.getPassword() : sipConfig.getPassword(); String password = (device != null && !ObjectUtils.isEmpty(device.getPassword()))? device.getPassword() : sipConfig.getPassword();