package com.ruoyi.project.common.service;

import com.ruoyi.project.common.domain.Message;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

import java.util.List;

/**
 * @Author: zhaoby
 * @date: 2023-11-29 9:16:46
 */
public interface ISseEmitterService {
    /**
     * 创建连接
     *
     * @param clientId 客户端ID
     */
    SseEmitter createConnect(String clientId, String lastEventId);


    /**
     * 根据客户端id获取SseEmitter对象
     *
     * @param clientId 客户端ID
     */
    SseEmitter getSseEmitterByClientId(String clientId);

    /**
     * 发送消息给所有客户端
     *
     * @param msg 消息内容
     */
    void sendMessageToAllClient(String msg);

    /**
     * 给指定客户端发送消息
     *
     * @param clientId 客户端ID
     * @param msg      消息内容
     */
    void sendMessageToOneClient(String clientId, Object msg);


    void sendMessageToUserId(Long clientId, boolean popUpFlag);

    void sendMessageToUserIdList(List<Long> clientIdList, boolean popUpFlag);

    /**
     * 关闭连接
     *
     * @param clientId 客户端ID
     */
    void closeConnect(String clientId);

    String sendSaveMessage(List<Long> userIds, Message message);
}
