修复:只有绘画事件是发送给非自己的房间人员,其余消息房间全员发送
This commit is contained in:
@@ -9,6 +9,7 @@ public class DrawAndGuessApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DrawAndGuessApplication.class, args);
|
||||
// 加载题库
|
||||
TopicService.loadTopics();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ public class Brush {
|
||||
/**
|
||||
* 画笔粗细
|
||||
*/
|
||||
private String width;
|
||||
private Integer width;
|
||||
/**
|
||||
* 画笔坐标点
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.airnan.dg.entity;
|
||||
|
||||
import cn.airnan.dg.configs.Global;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -85,15 +86,22 @@ public class Room {
|
||||
* @param playerId 发送者的ID(用于排除发送者)
|
||||
*/
|
||||
public void sendMessage(String type, String playerId, String message) {
|
||||
log.info("【房间消息】{}: {}", id, message);
|
||||
for (Player player : players) {
|
||||
// 向除自己之外的玩家发送消息
|
||||
// if (!player.getId().equals(playerId)) {
|
||||
// player.sendMessage(type, message);
|
||||
// }
|
||||
// 向房间内所有玩家发送
|
||||
player.sendMessage(type, message);
|
||||
if (type.equals(Global.MSG_TYPE_ROOM_DRAW)) {
|
||||
log.info("【绘画房间消息】{}: {}", id, message);
|
||||
for (Player player : players) {
|
||||
// 向除自己之外的玩家发送消息
|
||||
if (!player.getId().equals(playerId)) {
|
||||
player.sendMessage(type, message);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.info("【全员房间消息】{}: {}", id, message);
|
||||
for (Player player : players) {
|
||||
// 向房间内所有玩家发送
|
||||
player.sendMessage(type, message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user