Spring Boot向所有客户端推送通知

时间:2020-09-02 13:36:38

标签: spring-boot vue.js notifications server-sent-events

我有一个Web应用程序,它使用spring boot作为后端,而vue.js作为前端,并且我有一个脚本python捕获帧,当获取信息时将其设置为服务器,最后将一行添加到数据库,所以要在服务器添加到数据库时在前面收到通知

@PostMapping("/plate")
public ResponseEntity<Void> createPositionOc(@RequestParam String plate) {

    LocalDateTime myDateObj = LocalDateTime.now();
    DateTimeFormatter myFormatObj = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    List<Car> cars = carController.getAllCars();
    boolean exist = cars.stream().anyMatch(o -> o.getPlate().equals(plate));

    List<Car> carsIn = carController.getAllCarsIn();
    boolean existIn = carsIn.stream().anyMatch(o -> o.getPlate().equals(plate));


    List<Position> free = getAllPositiosFree();

    PositionOcp position = new PositionOcp(free.get(0).getId_pos(), plate, 
 myDateObj.format(myFormatObj));

    if (exist && free.size() > 0 && !existIn) {
        PositionOcp createdPositionOc = positionOcpRepository.save(position);
        //send notification
    }    

    return null;
}

0 个答案:

没有答案