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
|
@Override
|
||||||
public void onOpen(WebSocket conn, ClientHandshake handshake) {
|
public void onOpen(WebSocket conn, ClientHandshake handshake) {
|
||||||
Logger.info("New client connected. Adding new User.");
|
Logger.info("New client connected. Adding new User.");
|
||||||
userManager.connectUser(conn);
|
UserManager.getInstance().connectUser(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClose(WebSocket conn, int code, String reason, boolean remote) {
|
public void onClose(WebSocket conn, int code, String reason, boolean remote) {
|
||||||
Logger.info("Client disconnected");
|
Logger.info("Client disconnected");
|
||||||
userManager.disconnectUser(conn, remote);
|
UserManager.getInstance().disconnectUser(conn, remote);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onMessage(WebSocket conn, String message) {
|
public void onMessage(WebSocket conn, String message) {
|
||||||
Logger.debug("Message received: {}", message);
|
Logger.debug("Message received: {}", message);
|
||||||
userManager.messageReceived(conn, message);
|
UserManager.getInstance().messageReceived(conn, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -37,16 +37,7 @@ public class MarvelousServer extends WebSocketServer {
|
|||||||
Logger.info("MarvelousServer started on Address {}", this.getAddress().toString());
|
Logger.info("MarvelousServer started on Address {}", this.getAddress().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private final UserManager userManager;
|
|
||||||
|
|
||||||
public MarvelousServer(InetSocketAddress address) {
|
public MarvelousServer(InetSocketAddress address) {
|
||||||
super(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