优化移动位置notify消息处理
This commit is contained in:
parent
160e97a13a
commit
ba2591aeea
@ -148,26 +148,30 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
|
||||
|
||||
MobilePosition mobilePosition = new MobilePosition();
|
||||
mobilePosition.setCreateTime(DateUtil.getNow());
|
||||
|
||||
Element deviceIdElement = rootElement.element("DeviceID");
|
||||
String channelId = deviceIdElement.getTextTrim().toString();
|
||||
Device device = redisCatchStorage.getDevice(deviceId);
|
||||
|
||||
if (device == null) {
|
||||
// 根据通道id查询设备Id
|
||||
List<Device> deviceList = deviceChannelService.getDeviceByChannelId(channelId);
|
||||
if (deviceList.size() > 0) {
|
||||
device = deviceList.get(0);
|
||||
}else {
|
||||
logger.warn("[mobilePosition移动位置Notify] 未找到通道{}所属的设备", channelId);
|
||||
return;
|
||||
device = redisCatchStorage.getDevice(channelId);
|
||||
if (device == null) {
|
||||
// 根据通道id查询设备Id
|
||||
List<Device> deviceList = deviceChannelService.getDeviceByChannelId(channelId);
|
||||
if (deviceList.size() > 0) {
|
||||
device = deviceList.get(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (device != null) {
|
||||
if (!ObjectUtils.isEmpty(device.getName())) {
|
||||
mobilePosition.setDeviceName(device.getName());
|
||||
}
|
||||
if (device == null) {
|
||||
logger.warn("[mobilePosition移动位置Notify] 未找到通道{}所属的设备", channelId);
|
||||
return;
|
||||
}
|
||||
mobilePosition.setDeviceId(XmlUtil.getText(rootElement, "DeviceID"));
|
||||
if (!ObjectUtils.isEmpty(device.getName())) {
|
||||
mobilePosition.setDeviceName(device.getName());
|
||||
}
|
||||
|
||||
mobilePosition.setDeviceId(device.getDeviceId());
|
||||
mobilePosition.setChannelId(channelId);
|
||||
String time = XmlUtil.getText(rootElement, "Time");
|
||||
mobilePosition.setTime(time);
|
||||
|
@ -81,7 +81,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
|
||||
try {
|
||||
RequestEventExt evtExt = (RequestEventExt) evt;
|
||||
String requestAddress = evtExt.getRemoteIpAddress() + ":" + evtExt.getRemotePort();
|
||||
logger.info("[注册请求] 开始处理: {}", requestAddress);
|
||||
|
||||
// MBeanServer beanServer = ManagementFactory.getPlatformMBeanServer();
|
||||
// QueryExp protocol = Query.match(Query.attr("protocol"), Query.value("HTTP/1.1"));
|
||||
//// ObjectName name = new ObjectName("*:type=Connector,*");
|
||||
@ -104,6 +104,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
|
||||
AddressImpl address = (AddressImpl) fromHeader.getAddress();
|
||||
SipUri uri = (SipUri) address.getURI();
|
||||
String deviceId = uri.getUser();
|
||||
logger.info("[注册请求] 设备:{}, 开始处理: {}", deviceId, requestAddress);
|
||||
Device device = deviceService.getDevice(deviceId);
|
||||
|
||||
RemoteAddressInfo remoteAddressInfo = SipUtils.getRemoteAddressFromRequest(request,
|
||||
@ -112,7 +113,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
|
||||
if (device != null &&
|
||||
device.getSipTransactionInfo() != null &&
|
||||
request.getCallIdHeader().getCallId().equals(device.getSipTransactionInfo().getCallId())) {
|
||||
logger.info("[注册请求] 注册续订: {}", device.getDeviceId());
|
||||
logger.info("[注册请求] 设备:{}, 注册续订: {}",device.getDeviceId(), device.getDeviceId());
|
||||
device.setExpires(request.getExpires().getExpires());
|
||||
device.setIp(remoteAddressInfo.getIp());
|
||||
device.setPort(remoteAddressInfo.getPort());
|
||||
@ -132,7 +133,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
|
||||
String password = (device != null && !ObjectUtils.isEmpty(device.getPassword()))? device.getPassword() : sipConfig.getPassword();
|
||||
AuthorizationHeader authHead = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME);
|
||||
if (authHead == null && !ObjectUtils.isEmpty(password)) {
|
||||
logger.info("[注册请求] 回复401: {}", requestAddress);
|
||||
logger.info("[注册请求] 设备:{}, 回复401: {}",deviceId, requestAddress);
|
||||
response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request);
|
||||
new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getDomain());
|
||||
sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response);
|
||||
@ -147,7 +148,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
|
||||
// 注册失败
|
||||
response = getMessageFactory().createResponse(Response.FORBIDDEN, request);
|
||||
response.setReasonPhrase("wrong password");
|
||||
logger.info("[注册请求] 密码/SIP服务器ID错误, 回复403: {}", requestAddress);
|
||||
logger.info("[注册请求] 设备:{}, 密码/SIP服务器ID错误, 回复403: {}", deviceId, requestAddress);
|
||||
sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response);
|
||||
return;
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ public class PlayServiceImpl implements IPlayService {
|
||||
// 检查是否有y字段
|
||||
if (ssrcIndex >= 0) {
|
||||
//ssrc规定长度为10字节,不取余下长度以避免后续还有“f=”字段 TODO 后续对不规范的非10位ssrc兼容
|
||||
String ssrcInResponse = contentString.substring(ssrcIndex + 2, ssrcIndex + 12);
|
||||
String ssrcInResponse = contentString.substring(ssrcIndex + 2, ssrcIndex + 12).trim();
|
||||
// 查询到ssrc不一致且开启了ssrc校验则需要针对处理
|
||||
if (ssrcInfo.getSsrc().equals(ssrcInResponse)) {
|
||||
return;
|
||||
|
@ -1,15 +1,18 @@
|
||||
package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DeviceMobilePositionMapper {
|
||||
|
||||
@Insert("INSERT INTO device_mobile_position (deviceId,channelId, deviceName, time, longitude, latitude, altitude, speed, direction, reportSource, longitudeGcj02, latitudeGcj02, longitudeWgs84, latitudeWgs84, createTime) " +
|
||||
"VALUES (#{deviceId},#{channelId}, #{deviceName}, #{time}, #{longitude}, #{latitude}, #{altitude}, #{speed}, #{direction}, #{reportSource}, #{longitudeGcj02}, #{latitudeGcj02}, #{longitudeWgs84}, #{latitudeWgs84}, #{createTime})")
|
||||
"VALUES (#{deviceId}, #{channelId}, #{deviceName}, #{time}, #{longitude}, #{latitude}, #{altitude}, #{speed}, #{direction}, #{reportSource}, #{longitudeGcj02}, #{latitudeGcj02}, #{longitudeWgs84}, #{latitudeWgs84}, #{createTime})")
|
||||
int insertNewPosition(MobilePosition mobilePosition);
|
||||
|
||||
@Select(value = {" <script>" +
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user