package com.bohuikeji.frame.module.admin.listener;

import com.bohuikeji.frame.module.admin.base.MqListener;
import com.bohuikeji.frame.module.admin.entity.socket.Smsg;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Service;

/**
 * socket消息发送
 * @author 孙劲辉
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class SocketMsgListener extends MqListener<Smsg> {

    final SimpMessagingTemplate messagingTemplate;

    @Override
    public boolean onReceive(Smsg msg) {
        messagingTemplate.convertAndSend(msg.getUrl(),msg.getData());
        return true;
    }

    @Override
    public void onError(Smsg msg, Exception e) {

    }
}
