From 18393417346a4b4276c6cf1df0280ca1b6d6946b Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Sun, 6 Jun 2021 03:50:04 +0200 Subject: [PATCH] feat: adjusted singleton pattern in MarvelousServer --- .../server/netconnector/MarvelousServer.java | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/netconnector/MarvelousServer.java b/Server/src/main/java/uulm/teamname/marvelous/server/netconnector/MarvelousServer.java index ca30d06..1a761e8 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/netconnector/MarvelousServer.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/netconnector/MarvelousServer.java @@ -12,19 +12,19 @@ public class MarvelousServer extends WebSocketServer { @Override public void onOpen(WebSocket conn, ClientHandshake handshake) { Logger.info("New client connected. Adding new User."); - userManager.connectUser(conn); + UserManager.getInstance().connectUser(conn); } @Override public void onClose(WebSocket conn, int code, String reason, boolean remote) { Logger.info("Client disconnected"); - userManager.disconnectUser(conn, remote); + UserManager.getInstance().disconnectUser(conn, remote); } @Override public void onMessage(WebSocket conn, String message) { Logger.debug("Message received: {}", message); - userManager.messageReceived(conn, message); + UserManager.getInstance().messageReceived(conn, message); } @Override @@ -37,16 +37,7 @@ public class MarvelousServer extends WebSocketServer { Logger.info("MarvelousServer started on Address {}", this.getAddress().toString()); } - private final UserManager userManager; - public MarvelousServer(InetSocketAddress address) { super(address); - this.userManager = new UserManager(); - } - - /** Practically No-Arg constructor for testing. NEVER USE ANYWHERE ELSE! - * @param userManager*/ - protected MarvelousServer(UserManager userManager) { super(); - this.userManager = userManager; } }