backend/src/main/java/com/coolioasjulio/influence/web/Lobby.java
/**
     * Called when this lobby has timed out. (been sitting for too long without starting or terminating)
     */
Called when this lobby has timed out. (been sitting for too long without starting or terminating)
Called when this lobby has timed out . ( been sitting for too long without starting or terminating )
private void timedOut() {
        boolean inMap;
        synchronized (lobbyMapLock) {
            inMap = lobbyMap.get(code) == this;
        }
        if (!isStarted() && inMap) {
            for (PlayerEndpoint endpoint : players) {
                try {
                    endpoint.close("The lobby has been inactive for too long!");
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            synchronized (lobbyMapLock) {
                if (lobbyMap.get(code) == this) {
                    lobbyMap.remove(code);
                }
            }
        }
    }
private void timedOut ( ) { boolean inMap ; synchronized ( lobbyMapLock ) { inMap = lobbyMap . get ( code ) == this ; } if ( ! isStarted ( ) && inMap ) { for ( PlayerEndpoint endpoint : players ) { try { endpoint . close ( "The lobby has been inactive for too long!" ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } } synchronized ( lobbyMapLock ) { if ( lobbyMap . get ( code ) == this ) { lobbyMap . remove ( code ) ; } } } }
Called when this lobby has timed out.
Called when this lobby has timed out .
// Only do anything if the game has not already started and it's still available in the lobby map // Disconnect all players // No need to call removePlayer(), the endpoint will call it when it disconnects // Re-synchronize on the map to remove this lobby from the map // Ensure that this lobby is still associated to this code