优化报警推送心跳定时任务

pull/1669/head
648540858 2024-10-29 09:22:04 +08:00
parent bf9262283e
commit caaaaacb89
3 changed files with 26 additions and 23 deletions

View File

@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.gb28181.controller; package com.genersoft.iot.vmp.gb28181.controller;
import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEventListener; import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEventListener;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -28,6 +29,9 @@ public class SseController {
@Resource @Resource
private AlarmEventListener alarmEventListener; private AlarmEventListener alarmEventListener;
@Resource
private DynamicTask dynamicTask;
/** /**
* SSE . * SSE .
* *
@ -45,11 +49,13 @@ public class SseController {
PrintWriter writer = response.getWriter(); PrintWriter writer = response.getWriter();
alarmEventListener.addSseEmitter(browserId, writer); alarmEventListener.addSseEmitter(browserId, writer);
while (!writer.checkError()) { dynamicTask.startCron("sse-key", new Runnable() {
Thread.sleep(1000); @Override
public void run() {
writer.write(":keep alive\n\n"); writer.write(":keep alive\n\n");
writer.flush(); writer.flush();
} }
}, 1000);
alarmEventListener.removeSseEmitter(browserId, writer); alarmEventListener.removeSseEmitter(browserId, writer);
} }
} }

View File

@ -7,14 +7,13 @@ import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.GbSipDate; import com.genersoft.iot.vmp.gb28181.bean.GbSipDate;
import com.genersoft.iot.vmp.gb28181.bean.RemoteAddressInfo; import com.genersoft.iot.vmp.gb28181.bean.RemoteAddressInfo;
import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo;
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver;
import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; import com.genersoft.iot.vmp.gb28181.transmit.SIPSender;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.DateUtil;
import gov.nist.javax.sip.RequestEventExt;
import gov.nist.javax.sip.address.AddressImpl; import gov.nist.javax.sip.address.AddressImpl;
import gov.nist.javax.sip.address.SipUri; import gov.nist.javax.sip.address.SipUri;
import gov.nist.javax.sip.header.SIPDateHeader; import gov.nist.javax.sip.header.SIPDateHeader;
@ -77,8 +76,6 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
@Override @Override
public void process(RequestEvent evt) { public void process(RequestEvent evt) {
try { try {
RequestEventExt evtExt = (RequestEventExt) evt;
SIPRequest request = (SIPRequest) evt.getRequest(); SIPRequest request = (SIPRequest) evt.getRequest();
Response response = null; Response response = null;
boolean passwordCorrect = false; boolean passwordCorrect = false;

View File

@ -120,7 +120,7 @@ export default {
that.$notify({ that.$notify({
title: '报警信息', title: '报警信息',
dangerouslyUseHTMLString: true, dangerouslyUseHTMLString: true,
message: `<strong>设备</strong> <i> ${data.deviceId}</i>` + message: `<strong>设备编号</strong> <i> ${data.deviceId}</i>` +
`<br><strong>通道编号:</strong> <i>${ data.channelId}</i>` + `<br><strong>通道编号:</strong> <i>${ data.channelId}</i>` +
`<br><strong>报警级别:</strong> <i>${ data.alarmPriorityDescription}</i>` + `<br><strong>报警级别:</strong> <i>${ data.alarmPriorityDescription}</i>` +
`<br><strong>报警方式:</strong> <i>${ data.alarmMethodDescription}</i>` + `<br><strong>报警方式:</strong> <i>${ data.alarmMethodDescription}</i>` +