|
|
@ -6,6 +6,11 @@ import com.ccsens.game.bean.dto.message.GameMessageWithChangeStatusOut; |
|
|
|
import com.ccsens.game.bean.po.GameRecord; |
|
|
|
import com.ccsens.game.bean.po.GameUserJoin; |
|
|
|
import com.ccsens.game.persist.dao.GameUserJoinDao; |
|
|
|
import com.ccsens.util.JacksonUtil; |
|
|
|
import com.ccsens.util.config.RabbitMQConfig; |
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.amqp.core.AmqpTemplate; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -21,9 +26,12 @@ import java.util.concurrent.TimeUnit; |
|
|
|
* @create: 2019/12/28 15:49 |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
@Slf4j |
|
|
|
public class SendMsg { |
|
|
|
@Autowired |
|
|
|
private GameUserJoinDao gameUserJoinDao; |
|
|
|
@Autowired |
|
|
|
private AmqpTemplate rabbitTemplate; |
|
|
|
|
|
|
|
public void sendStatus(GameRecord gameRecord, List<GameUserJoin> userJoins, byte status) { |
|
|
|
List<GameMessageWithChangeStatusOut> outs = new ArrayList<>(); |
|
|
@ -31,7 +39,14 @@ public class SendMsg { |
|
|
|
outs.add(getMsg(gameRecord, join, status)); |
|
|
|
}); |
|
|
|
if (CollectionUtil.isNotEmpty(outs)) { |
|
|
|
//TODO fasong
|
|
|
|
try { |
|
|
|
rabbitTemplate.convertAndSend(RabbitMQConfig.RabbitMQ_QUEUE_NAME, |
|
|
|
JacksonUtil.beanToJson(outs)); |
|
|
|
} catch (JsonProcessingException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
log.error("通知游戏状态变更mq异常"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|