WVPTimerTask.java 1002 B

123456789101112131415161718192021222324252627282930313233
  1. package com.genersoft.iot.vmp.conf;
  2. import com.alibaba.fastjson2.JSONObject;
  3. import com.genersoft.iot.vmp.service.IMediaServerService;
  4. import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.beans.factory.annotation.Value;
  7. import org.springframework.scheduling.annotation.Scheduled;
  8. import org.springframework.stereotype.Component;
  9. @Component
  10. public class WVPTimerTask {
  11. @Autowired
  12. private IRedisCatchStorage redisCatchStorage;
  13. @Autowired
  14. private IMediaServerService mediaServerService;
  15. @Value("${server.port}")
  16. private int serverPort;
  17. @Autowired
  18. private SipConfig sipConfig;
  19. @Scheduled(fixedRate = 2 * 1000) //每3秒执行一次
  20. public void execute(){
  21. JSONObject jsonObject = new JSONObject();
  22. jsonObject.put("ip", sipConfig.getIp());
  23. jsonObject.put("port", serverPort);
  24. redisCatchStorage.updateWVPInfo(jsonObject, 3);
  25. }
  26. }