feat: adjusted singleton pattern in MarvelousServer
This commit is contained in:
parent
0ee264502c
commit
1839341734
@ -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. <b>NEVER USE ANYWHERE ELSE!</b>
|
||||
* @param userManager*/
|
||||
protected MarvelousServer(UserManager userManager) { super();
|
||||
this.userManager = userManager;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user