办学质量监测教学评价系统
ageerle
2025-05-27 bd94a3eae8ea1fa65b9298335cbce47a5ce4ad44
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package org.ruoyi.chat.util;
 
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitter;
 
import java.io.IOException;
 
/**
 * sse工具类
 *
 * @author WangLe
 */
@Slf4j
public class SSEUtil {
 
    /**
     * 发送SSE错误事件的封装方法
     *
     * @param sseEmitter sse事件对象
     * @param errorMessage 错误信息
     */
    public static void sendErrorEvent(ResponseBodyEmitter sseEmitter, String errorMessage) {
        try {
            sseEmitter.send(errorMessage);
        } catch (IOException e) {
            log.error("SSE发送失败: {}", e.getMessage());
        }
        sseEmitter.complete();
    }
}