package org.jeecg.modules.adweb.common.service;

import com.alibaba.fastjson.JSONObject;

import jakarta.annotation.Resource;

import org.jeecg.common.constant.WebsocketConst;
import org.jeecg.modules.message.websocket.WebSocket;
import org.springframework.stereotype.Service;

/**
 * websocket 发送消息服务
 *
 * @author 陈培庆
 */
@Service
public class WebSocketService {

    @Resource
    private WebSocket webSocket;

    public void sendMessage(String[] userIds, String title, String message, String CMD) {
        JSONObject obj = new JSONObject();
        obj.put(WebsocketConst.MSG_CMD, CMD);
        obj.put(WebsocketConst.MSG_TITLE, title);
        obj.put(WebsocketConst.MSG_TXT, message);
        webSocket.sendMessage(userIds, obj.toJSONString());
    }
}
