Search in sources :

Example 6 with MsgProducer

use of com.code.server.kafka.MsgProducer 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)

Example 7 with MsgProducer

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

the class Room method clubRoomSetId.

/**
 * 俱乐部 设置id
 */
public void clubRoomSetId() {
    if (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", "clubRoomSetId", msg);
        msgProducer.send("clubService", kafkaKey, responseVo);
    }
}
Also used : MsgProducer(com.code.server.kafka.MsgProducer) KafkaMsgKey(com.code.server.constant.kafka.KafkaMsgKey)

Example 8 with MsgProducer

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

the class GameClubService method invite.

/**
 * 邀请其他玩家
 *
 * @param msgKey
 * @param clubId
 * @param roomId
 * @param inviteUser
 * @return
 */
public int invite(KafkaMsgKey msgKey, String clubId, String roomId, String inviteUser, String roomModel, String name) {
    Club club = ClubManager.getInstance().getClubById(clubId);
    if (club == null) {
        return ErrorCode.CLUB_NO_THIS;
    }
    MsgProducer msgProducer = SpringUtil.getBean(MsgProducer.class);
    Map<String, Object> result = new HashMap<>();
    result.put("clubId", clubId);
    result.put("roomId", roomId);
    result.put("inviteUser", inviteUser);
    result.put("roomModelInfo", getRoomModel(club, roomModel));
    result.put("name", name);
    msgProducer.send();
    sendMsg2Player(new ResponseVo("clubService", "inviteUser", result), Long.valueOf(inviteUser));
    sendMsg(msgKey, new ResponseVo("clubService", "invite", "ok"));
    return 0;
}
Also used : MsgProducer(com.code.server.kafka.MsgProducer) HashMap(java.util.HashMap) Club(com.code.server.db.model.Club) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 9 with MsgProducer

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

the class GameClubService method sendMsgForCreateRoom.

/**
 * 向逻辑服务器 发送创建的内部消息
 *
 * @param serviceName
 * @param createCommand
 */
private static void sendMsgForCreateRoom(String serviceName, String createCommand) {
    MsgProducer msgProducer = SpringUtil.getBean(MsgProducer.class);
    int serverId = getServerIdByServiceName(serviceName);
    KafkaMsgKey msgKey = new KafkaMsgKey();
    msgKey.setUserId(0);
    msgProducer.send2Partition(serviceName, serverId, JsonUtil.toJson(msgKey), createCommand);
}
Also used : MsgProducer(com.code.server.kafka.MsgProducer) KafkaMsgKey(com.code.server.constant.kafka.KafkaMsgKey)

Example 10 with MsgProducer

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

the class GameInfo method genRecord.

@Override
protected void genRecord() {
    long id = IdWorker.getDefaultInstance().nextId();
    genRecord(playerCardsInfos.values().stream().collect(Collectors.toMap(PlayerCardsInfoMj::getUserId, PlayerCardsInfoMj::getScore)), room, id);
    replay.setId(id);
    replay.setCount(playerCardsInfos.size());
    replay.setRoom_uuid(this.room.getUuid());
    replay.setRoomInfo(this.getRoom().toJSONObject());
    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

MsgProducer (com.code.server.kafka.MsgProducer)14 KafkaMsgKey (com.code.server.constant.kafka.KafkaMsgKey)13 HashMap (java.util.HashMap)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 GameRecord (com.code.server.constant.game.GameRecord)1 RoomRecord (com.code.server.constant.game.RoomRecord)1 Club (com.code.server.db.model.Club)1