package org.eco.system.controller.monitor;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.eco.common.core.core.domain.CommonResult;
import org.eco.common.websocket.dto.WebSocketMessageDto;
import org.eco.common.websocket.utils.WebSocketUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: WeSocketController
 * @Author: GaoKun Wang
 * @Date: 2024/7/1
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/demo/websocket")
@Slf4j
public class WeSocketController {
    /**
     * 发布消息
     *
     * @param dto 发送内容
     */
    @GetMapping("/send")
    public CommonResult<Void> send(WebSocketMessageDto dto) throws InterruptedException {
        WebSocketUtils.publishMessage(dto);
        return CommonResult.success("操作成功");
    }
}
