package com.zcxk.mq;

import com.alibaba.fastjson.JSONObject;
import com.zcxk.Dto.MessageDto;
import com.zcxk.util.WebSocketUtil;

import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Component;

@Component
public class ReceiveMessage {
    @Autowired
    private WebSocketUtil webSocketUtil;
    @RabbitListener(queues = "${receive.queue.name}")
    public void receive(String message){
        MessageDto sendMessage = JSONObject.parseObject(message, MessageDto.class);
        webSocketUtil.sendInfo(sendMessage.getUserId(),
               JSONObject.toJSONString(sendMessage));
    }

}
