use of com.code.server.constant.kafka.KafkaMsgKey in project summer by foxsugar.
the class TTZRobot method getReady.
@Override
public void getReady(RoomTuiTongZi room) {
String roomId = room.getRoomId();
int partition = SpringUtil.getBean(ServerConfig.class).getServerId();
KafkaMsgKey msgKey = new KafkaMsgKey();
msgKey.setRoomId(roomId);
msgKey.setPartition(partition);
for (Long l : room.getUserStatus().keySet()) {
if (0 == room.getUserStatus().get(l)) {
msgKey.setUserId(l);
}
}
Map<String, Object> put = new HashMap();
ResponseRobotVo result = new ResponseRobotVo("roomService", "getReady", put);
SpringUtil.getBean(MsgProducer.class).send2Partition("roomService", partition, msgKey, result);
}
use of com.code.server.constant.kafka.KafkaMsgKey in project summer by foxsugar.
the class TTZRobot method bet.
@Override
public void bet(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();
put.put("zhu", 1);
for (PlayerTuiTongZi p : game.getPlayerCardInfos().values()) {
if (p.getUserId() != game.room.getBankerId() && p.getBet() == null) {
msgKey.setUserId(p.getUserId());
put.put("userId", p.getUserId());
}
}
ResponseRobotVo result = new ResponseRobotVo("gameService", "bet", put);
SpringUtil.getBean(MsgProducer.class).send2Partition("gameService", partition, msgKey, result);
}
use of com.code.server.constant.kafka.KafkaMsgKey in project summer by foxsugar.
the class Game method genRecord.
protected void genRecord(Map<Long, Double> scores, Room room, long id) {
Map<String, Object> data = new HashMap<>();
data.put("count", scores.size());
data.put("room_uuid", room.getUuid());
data.put("replay_id", id);
GameRecord gameRecord = new GameRecord();
gameRecord.setCurGameNumber(room.getCurGameNumber());
scores.forEach((key, value) -> {
UserRecord userRecord = new UserRecord();
userRecord.setScore(value);
userRecord.setUserId(key);
userRecord.setRoomId(room.getRoomId());
UserBean userBean = RedisManager.getUserRedisService().getUserBean(key);
if (userBean != null) {
userRecord.setName(userBean.getUsername());
}
gameRecord.getRecords().add(userRecord);
});
data.put("record", JsonUtil.toJson(gameRecord));
KafkaMsgKey kafkaMsgKey = new KafkaMsgKey().setMsgId(KAFKA_MSG_ID_GAME_RECORD);
MsgProducer msgProducer = SpringUtil.getBean(MsgProducer.class);
msgProducer.send(IKafaTopic.CENTER_TOPIC, kafkaMsgKey, data);
}
use of com.code.server.constant.kafka.KafkaMsgKey in project summer by foxsugar.
the class Room method getRoomClubByUser.
@Override
public int getRoomClubByUser(long userId) {
Map<String, Object> result = new HashMap<>();
result.put("userId", userId);
if (this.clubId == null) {
result.put("clubId", 0);
MsgSender.sendMsg2Player(new ResponseVo("roomService", "getRoomClubByUser", result), userId);
} else {
result.put("clubId", this.clubId);
KafkaMsgKey kafkaMsgKey = new KafkaMsgKey().setMsgId(KAFKA_MSG_ID_ROOM_CLUB_USER);
MsgProducer msgProducer = SpringUtil.getBean(MsgProducer.class);
msgProducer.send(IKafaTopic.CENTER_TOPIC, kafkaMsgKey, result);
}
return 0;
}
use of com.code.server.constant.kafka.KafkaMsgKey in project summer by foxsugar.
the class Room method genRoomRecord.
/**
* 生成房间战绩
*/
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(clubId);
roomRecord.setClubRoomModel(clubRoomModel);
this.userScores.forEach((key, value) -> {
UserRecord userRecord = new UserRecord();
userRecord.setScore(value);
userRecord.setUserId(key);
UserBean userBean = RedisManager.getUserRedisService().getUserBean(key);
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);
}
Aggregations