修复:只有绘画事件是发送给非自己的房间人员,其余消息房间全员发送

This commit is contained in:
2024-04-14 16:26:22 +08:00
parent 532e23938a
commit e86e1794ca
3 changed files with 18 additions and 9 deletions
@@ -9,6 +9,7 @@ public class DrawAndGuessApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(DrawAndGuessApplication.class, args); SpringApplication.run(DrawAndGuessApplication.class, args);
// 加载题库
TopicService.loadTopics(); TopicService.loadTopics();
} }
+1 -1
View File
@@ -19,7 +19,7 @@ public class Brush {
/** /**
* 画笔粗细 * 画笔粗细
*/ */
private String width; private Integer width;
/** /**
* 画笔坐标点 * 画笔坐标点
*/ */
+16 -8
View File
@@ -1,5 +1,6 @@
package cn.airnan.dg.entity; package cn.airnan.dg.entity;
import cn.airnan.dg.configs.Global;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@@ -85,15 +86,22 @@ public class Room {
* @param playerId 发送者的ID(用于排除发送者) * @param playerId 发送者的ID(用于排除发送者)
*/ */
public void sendMessage(String type, String playerId, String message) { public void sendMessage(String type, String playerId, String message) {
log.info("【房间消息】{}: {}", id, message); if (type.equals(Global.MSG_TYPE_ROOM_DRAW)) {
for (Player player : players) { log.info("【绘画房间消息】{}: {}", id, message);
// 向除自己之外的玩家发送消息 for (Player player : players) {
// if (!player.getId().equals(playerId)) { // 向除自己之外的玩家发送消息
// player.sendMessage(type, message); if (!player.getId().equals(playerId)) {
// } player.sendMessage(type, message);
// 向房间内所有玩家发送 }
player.sendMessage(type, message); }
} else {
log.info("【全员房间消息】{}: {}", id, message);
for (Player player : players) {
// 向房间内所有玩家发送
player.sendMessage(type, message);
}
} }
} }
} }