public static CtrlDomain getInstance() { if (INSTANCE == null) { INSTANCE = new CtrlDomain(); INSTANCE.NET = CtrlNet.getInstance(); INSTANCE.GAME = CtrlGame.getInstance(); } return INSTANCE; }
/** * A disconnection has been detected. Notify the UI if in client mode or notify the rest of the * clients if in server mode. * * @param conn */ public void disconnectionDetected(TCPConnection conn) { conn.close(); if (mode == CtrlDomain.MODE_CLIENT) { // If in client mode, notify the UI about the shutdown shutdownUI(); } else if (mode == CtrlDomain.MODE_SERVER && !gameRunning) { // This happens when there is a disconnection in the WaitingRoom CtrlNet.getInstance().removePlayer(conn); updatedPlayers(); } else if (mode == CtrlDomain.MODE_SERVER && gameRunning) { // This happens when there is a disconnection while playing a game CtrlNet.getInstance().sendShutdown(); } }