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);
}
}
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);
}
}
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;
}
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);
}
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);
}
Aggregations