package com.wzj.soopin.im.service.impl;

import com.wzj.soopin.im.domain.vo.SysMessageVo;
import com.wzj.soopin.im.service.IMessageWebSocketService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.system.websocket.MessageWebSocketServer;
import org.springframework.stereotype.Service;

/**
 * WebSocket消息服务实现类
 *
 * @author ruoyi
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class MessageWebSocketServiceImpl implements IMessageWebSocketService {

    private final MessageWebSocketServer messageWebSocketServer;

    @Override
    public void sendMessage(Long userId, SysMessageVo message) {
        messageWebSocketServer.sendMessage(userId, String.valueOf(message));
    }

    @Override
    public void broadcastMessage(SysMessageVo message) {
        messageWebSocketServer.broadcastMessage(String.valueOf(message));
    }
}
