Search in sources :

Example 6 with KafkaMsgKey

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

the class RoomGoldPaijiu method genRoomRecord.

/**
 * 生成房间战绩
 */
@Override
public void genRoomRecord() {
    RoomRecord roomRecord = new RoomRecord();
    roomRecord.setRoomId(this.roomId);
    roomRecord.setId(this.getUuid());
    roomRecord.setType(this.roomType);
    roomRecord.setTime(System.currentTimeMillis());
    roomRecord.setClubId(this.getClubId());
    roomRecord.setClubRoomModel(this.getClubRoomModel());
    for (Long l : userScoresForGold.keySet()) {
        UserRecord userRecord = new UserRecord();
        userRecord.setScore(userScoresForGold.get(l));
        userRecord.setUserId(l);
        UserBean userBean = RedisManager.getUserRedisService().getUserBean(l);
        if (userBean != null) {
            userRecord.setName(userBean.getUsername());
        }
        roomRecord.getRecords().add(userRecord);
    }
    KafkaMsgKey kafkaMsgKey = new KafkaMsgKey().setMsgId(KAFKA_MSG_ID_ROOM_RECORD);
    MsgProducer msgProducer = SpringUtil.getBean(MsgProducer.class);
    msgProducer.send(IKafaTopic.CENTER_TOPIC, kafkaMsgKey, roomRecord);
}
Also used : UserRecord(com.code.server.constant.game.UserRecord) UserBean(com.code.server.constant.game.UserBean) MsgProducer(com.code.server.kafka.MsgProducer) KafkaMsgKey(com.code.server.constant.kafka.KafkaMsgKey) RoomRecord(com.code.server.constant.game.RoomRecord)

Example 7 with KafkaMsgKey

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

the class TTZRobot method open.

@Override
public void open(GameTuiTongZi game) {
    String roomId = game.getRoom().getRoomId();
    int partition = SpringUtil.getBean(ServerConfig.class).getServerId();
    KafkaMsgKey msgKey = new KafkaMsgKey();
    msgKey.setRoomId(roomId);
    msgKey.setPartition(partition);
    Map<String, Object> put = new HashMap();
    for (PlayerTuiTongZi p : game.getPlayerCardInfos().values()) {
        if (!p.isOpen()) {
            msgKey.setUserId(p.getUserId());
            put.put("userId", p.getUserId());
        }
    }
    ResponseRobotVo result = new ResponseRobotVo("gameService", "open", 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 8 with KafkaMsgKey

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

the class TTZRobot method crap.

@Override
public void crap(GameTuiTongZi game) {
    String roomId = game.getRoom().getRoomId();
    int partition = SpringUtil.getBean(ServerConfig.class).getServerId();
    KafkaMsgKey msgKey = new KafkaMsgKey();
    msgKey.setRoomId(roomId);
    msgKey.setPartition(partition);
    Map<String, Object> put = new HashMap();
    for (PlayerTuiTongZi p : game.getPlayerCardInfos().values()) {
        if (p.getUserId() == game.room.getBankerId()) {
            msgKey.setUserId(p.getUserId());
            put.put("userId", p.getUserId());
        }
    }
    ResponseRobotVo result = new ResponseRobotVo("gameService", "crap", 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 9 with KafkaMsgKey

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

the class Room method clubDrawBack.

private void clubDrawBack() {
    MsgProducer msgProducer = SpringUtil.getBean(MsgProducer.class);
    KafkaMsgKey kafkaKey = new KafkaMsgKey();
    kafkaKey.setUserId(0);
    Map<String, Object> msg = new HashMap<>();
    msg.put("clubId", this.clubId);
    msg.put("clubModelId", this.clubRoomModel);
    ResponseVo responseVo = new ResponseVo("clubService", "clubDrawBack", msg);
    msgProducer.send("clubService", kafkaKey, responseVo);
}
Also used : MsgProducer(com.code.server.kafka.MsgProducer) KafkaMsgKey(com.code.server.constant.kafka.KafkaMsgKey)

Example 10 with KafkaMsgKey

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

the class Room method notifyCludGameStart.

/**
 * 通知 俱乐部游戏开始
 */
public void notifyCludGameStart() {
    if (!isOpen && isClubRoom()) {
        MsgProducer msgProducer = SpringUtil.getBean(MsgProducer.class);
        KafkaMsgKey kafkaKey = new KafkaMsgKey();
        kafkaKey.setUserId(0);
        Map<String, String> msg = new HashMap<>();
        msg.put("clubId", this.clubId);
        msg.put("clubModelId", this.clubRoomModel);
        msg.put("roomId", this.roomId);
        ResponseVo responseVo = new ResponseVo("clubService", "clubGameStart", msg);
        msgProducer.send("clubService", kafkaKey, responseVo);
    }
}
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