Search in sources :

Example 31 with KafkaMsgKey

use of com.code.server.constant.kafka.KafkaMsgKey in project summer by foxsugar.

the class DouDiZhuGoldRobot method jiaoDizhu.

@Override
public void jiaoDizhu(GameDouDiZhu game) {
    String roomId = game.getRoom().getRoomId();
    int partition = SpringUtil.getBean(ServerConfig.class).getServerId();
    KafkaMsgKey msgKey = new KafkaMsgKey();
    msgKey.setUserId(game.canJiaoUser);
    msgKey.setRoomId(roomId);
    msgKey.setPartition(partition);
    // 按service的名字 分topic
    // {"service":"gameService","method":"jiaoDizhu","params":{"isJiao":true,"score":3}}
    Map<String, Object> put = new HashMap<>();
    put.put("isJiao", false);
    ResponseRobotVo result = new ResponseRobotVo("gameService", "jiaoDizhu", put);
    SpringUtil.getBean(MsgProducer.class).send2Partition("gameService", partition, msgKey, result);
}
Also used : ServerConfig(com.code.server.game.poker.config.ServerConfig) HashMap(java.util.HashMap) MsgProducer(com.code.server.kafka.MsgProducer) KafkaMsgKey(com.code.server.constant.kafka.KafkaMsgKey) ResponseRobotVo(com.code.server.game.poker.robot.ResponseRobotVo)

Example 32 with KafkaMsgKey

use of com.code.server.constant.kafka.KafkaMsgKey in project summer by foxsugar.

the class GameDouDiZhu method genRecord.

protected void genRecord() {
    long id = IdWorker.getDefaultInstance().nextId();
    genRecord(playerCardInfos.values().stream().collect(Collectors.toMap(PlayerCardInfoDouDiZhu::getUserId, PlayerCardInfoDouDiZhu::getScore)), room, id);
    // 回放
    replay.setId(id);
    replay.setCount(playerCardInfos.size());
    replay.setRoom_uuid(this.room.getUuid());
    replay.setRoomInfo(this.room.toVo(0));
    KafkaMsgKey kafkaMsgKey = new KafkaMsgKey().setMsgId(KAFKA_MSG_ID_REPLAY);
    MsgProducer msgProducer = SpringUtil.getBean(MsgProducer.class);
    msgProducer.send(IKafaTopic.CENTER_TOPIC, kafkaMsgKey, replay);
}
Also used : MsgProducer(com.code.server.kafka.MsgProducer) KafkaMsgKey(com.code.server.constant.kafka.KafkaMsgKey)

Aggregations

KafkaMsgKey (com.code.server.constant.kafka.KafkaMsgKey)32 MsgProducer (com.code.server.kafka.MsgProducer)25 HashMap (java.util.HashMap)14 ServerConfig (com.code.server.game.poker.config.ServerConfig)11 ResponseRobotVo (com.code.server.game.poker.robot.ResponseRobotVo)11 JsonNode (com.fasterxml.jackson.databind.JsonNode)6 KafkaListener (org.springframework.kafka.annotation.KafkaListener)3 UserBean (com.code.server.constant.game.UserBean)2 UserRecord (com.code.server.constant.game.UserRecord)2 ResponseVo (com.code.server.constant.response.ResponseVo)2 UserServiceMsgDispatch (com.code.server.login.service.UserServiceMsgDispatch)2 CardStruct (com.code.server.constant.game.CardStruct)1 GameRecord (com.code.server.constant.game.GameRecord)1 RoomRecord (com.code.server.constant.game.RoomRecord)1 ClubServiceMsgDispatch (com.code.server.login.service.ClubServiceMsgDispatch)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1