From 7f717f5fe2f18a1f5afaebe92168aa8c2f6b60a3 Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Tue, 8 Jun 2021 02:33:06 +0200 Subject: [PATCH] feat: now ignoring empty request messages instead of sending them --- .../teamname/marvelous/server/lobby/Lobby.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/lobby/Lobby.java b/Server/src/main/java/uulm/teamname/marvelous/server/lobby/Lobby.java index 518e893..af01a65 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/lobby/Lobby.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/lobby/Lobby.java @@ -212,13 +212,15 @@ public class Lobby { } private void accept(Participant source, List accepted) { - Logger.debug("Accepting requests from participant '{}', broadcasting events to all except source", - source.id.getName()); - connection.broadcastToAllExcept(source, accepted.toArray(new Event[0])); + if (!accepted.isEmpty()) { + Logger.debug("Accepting requests from participant '{}', broadcasting events to all except source", + source.id.getName()); + connection.broadcastToAllExcept(source, accepted.toArray(new Event[0])); - Logger.trace("Adding ack and sending back to originParticipant"); - accepted.add(0, new EventBuilder(EventType.Ack).buildGameStateEvent()); - connection.sendEvents(source, accepted.toArray(new Event[0])); + Logger.trace("Adding ack and sending back to originParticipant"); + accepted.add(0, new EventBuilder(EventType.Ack).buildGameStateEvent()); + connection.sendEvents(source, accepted.toArray(new Event[0])); + } badRequests = 0; }