refactor: made WebSocket non-final for reconnect modularity

This commit is contained in:
Yannik Bretschneider 2021-06-05 00:54:22 +02:00
parent 69f77a1423
commit 903719e254
1 changed files with 25 additions and 1 deletions

View File

@ -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 +
'}';
}
}