EventPublisher.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package com.genersoft.iot.vmp.gb28181.event;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.context.ApplicationEventPublisher;
  4. import org.springframework.stereotype.Component;
  5. import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
  6. import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent;
  7. import com.genersoft.iot.vmp.gb28181.event.offline.OfflineEvent;
  8. import com.genersoft.iot.vmp.gb28181.event.online.OnlineEvent;
  9. /**
  10. * @Description:Event事件通知推送器,支持推送在线事件、离线事件
  11. * @author: swwheihei
  12. * @date: 2020年5月6日 上午11:30:50
  13. */
  14. @Component
  15. public class EventPublisher {
  16. @Autowired
  17. private ApplicationEventPublisher applicationEventPublisher;
  18. public void onlineEventPublish(String deviceId, String from) {
  19. OnlineEvent onEvent = new OnlineEvent(this);
  20. onEvent.setDeviceId(deviceId);
  21. onEvent.setFrom(from);
  22. applicationEventPublisher.publishEvent(onEvent);
  23. }
  24. public void outlineEventPublish(String deviceId, String from){
  25. OfflineEvent outEvent = new OfflineEvent(this);
  26. outEvent.setDeviceId(deviceId);
  27. outEvent.setFrom(from);
  28. applicationEventPublisher.publishEvent(outEvent);
  29. }
  30. /**
  31. * 设备报警事件
  32. * @param deviceAlarm
  33. */
  34. public void deviceAlarmEventPublish(DeviceAlarm deviceAlarm) {
  35. AlarmEvent alarmEvent = new AlarmEvent(this);
  36. alarmEvent.setAlarmInfo(deviceAlarm);
  37. applicationEventPublisher.publishEvent(alarmEvent);
  38. }
  39. }