use of com.code.server.constant.kafka.KafkaMsgKey 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.constant.kafka.KafkaMsgKey in project summer by foxsugar.
the class Server2ServerMsgDispatch method dispatch.
public static void dispatch(ConsumerRecord<String, String> record) {
KafkaMsgKey msgKey = JsonUtil.readValue(record.key(), KafkaMsgKey.class);
JsonNode params = JsonUtil.readTree(record.value());
// String service = params.get("service").asText();
String method = params.get("method").asText();
JsonNode node = params.get("params");
switch(method) {
case "kickUser":
kickUser(msgKey, node.path("roomId").asText(), node.path("kickUser").asLong());
break;
case "getRoomInfo":
getRoomInfo(msgKey, node.path("roomId").asText());
break;
}
}
use of com.code.server.constant.kafka.KafkaMsgKey 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.constant.kafka.KafkaMsgKey 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);
}
use of com.code.server.constant.kafka.KafkaMsgKey in project summer by foxsugar.
the class UserServiceMsgConsumer method listen.
@KafkaListener(id = "userService", topicPattern = "userService")
public void listen(ConsumerRecord<String, String> record) {
ThreadPool.getInstance().executor.execute(() -> {
String key = record.key();
String value = record.value();
KafkaMsgKey msgKey = JsonUtil.readValue(key, KafkaMsgKey.class);
JsonNode msgValue = JsonUtil.readTree(value);
UserServiceMsgDispatch userServiceMsgDispatch = SpringUtil.getBean(UserServiceMsgDispatch.class);
userServiceMsgDispatch.dispatchMsg(msgKey, msgValue);
});
}
Aggregations