From 903719e254a41f16151d479828dfbc71a348bb3b Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Sat, 5 Jun 2021 00:54:22 +0200 Subject: [PATCH] refactor: made WebSocket non-final for reconnect modularity --- .../server/lobbymanager/Participant.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/Participant.java b/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/Participant.java index bd25a11..1fe0747 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/Participant.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/lobbymanager/Participant.java @@ -8,7 +8,7 @@ import java.util.Objects; public class Participant { /** The Websocket to contact the participant with */ - public final WebSocket connection; + private WebSocket connection; /** The type (as in role) of participant */ public final ParticipantType type; @@ -23,6 +23,21 @@ public class Participant { this.AI = AI; } + /** Returns the {@link WebSocket} to contact the participant with */ + public WebSocket getConnection() { + return connection; + } + + /** Sets the connection {@link WebSocket} for the current participant */ + public void setConnection(WebSocket connection) { + this.connection = connection; + } + + /** Removes reference to current connection from Participant */ + public void clearConnection() { + this.connection = null; + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -35,4 +50,13 @@ public class Participant { public int hashCode() { return Objects.hash(connection, type, AI); } + + @Override + public String toString() { + return "Participant{" + + "connection=" + connection + + ", type=" + type + + ", AI=" + AI + + '}'; + } }