package p000; import com.m3gworks.engine.GameAppMidlet; import java.util.Timer; /* renamed from: an */ /* loaded from: microcounterstrike.jar:an.class */ public abstract class GameSessionLoop implements Runnable { /* renamed from: e */ private static GameSessionLoop instance; /* renamed from: a */ public int sessionType; /* renamed from: c */ public CountdownTimerTask countdownTask; /* renamed from: b */ public int sessionState = 5; /* renamed from: d */ public int roundEndTriggered = 0; /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Type inference failed for: r0v0, types: [an] */ /* JADX WARN: Type inference failed for: r0v1, types: [java.lang.Throwable] */ /* JADX WARN: Type inference failed for: r0v2, types: [java.lang.Throwable] */ /* JADX WARN: Type inference failed for: r0v6, types: [an] */ /* renamed from: a */ public static GameSessionLoop getInstance() { ?? r0 = instance; if (r0 == 0) { try { r0 = (GameSessionLoop) PlatformServices.getInstance().getGameModeClass().newInstance(); instance = r0; } catch (IllegalAccessException e) { r0.printStackTrace(); } catch (InstantiationException e2) { r0.printStackTrace(); } } return instance; } /* renamed from: b */ public final void start() { if (this.sessionState == 4 || this.sessionState == 5) { Thread thread = new Thread(this); this.roundEndTriggered = 0; thread.start(); } } /* JADX WARN: Multi-variable type inference failed */ /* JADX WARN: Type inference failed for: r0v16, types: [int] */ /* JADX WARN: Type inference failed for: r0v17, types: [java.lang.Throwable] */ /* JADX WARN: Type inference failed for: r0v20, types: [int] */ @Override // java.lang.Runnable public void run() { ?? r0; GameRenderCanvas c0002abM14c = GameRenderCanvas.getInstance(); GameAppMidlet.getInstance().display.setCurrent(c0002abM14c); onSessionStart(); this.sessionState = 1; this.countdownTask = new CountdownTimerTask(PlatformServices.getInstance().getPreRoundSeconds()); Timer timer = new Timer(); timer.schedule(this.countdownTask, 0L, 1000L); while (this.sessionState != 4 && (r0 = this.sessionState) != 5) { try { c0002abM14c.execute16(); r0 = this.sessionState; if (r0 == 1 && this.countdownTask.value11 == 0 && this.sessionType != 2) { this.sessionState = 2; this.countdownTask = null; if (MapManager.getInstance().getCurrentMapInfo().hasRoundTimer) { this.countdownTask = new CountdownTimerTask(180); timer.schedule(this.countdownTask, 0L, 1000L); } } if (this.sessionState == 2) { if ((MapManager.getInstance().getCurrentMapInfo().hasRoundTimer && this.countdownTask.value11 == 0) || this.roundEndTriggered != 0) { this.sessionState = 3; onRoundStart(); if (MapManager.getInstance().getCurrentMapInfo().hasRoundTimer) { this.countdownTask.cancel(); } this.countdownTask = new CountdownTimerTask(PlatformServices.getInstance().getRoundEndSeconds()); timer.schedule(this.countdownTask, 0L, 1000L); } } else if (this.sessionState == 3 && this.countdownTask.value11 == 0) { this.sessionState = 4; } Thread.yield(); } catch (Exception e) { r0.printStackTrace(); } } if (this.sessionState == 4) { onSessionEnd(); } if (this.sessionState == 5) { cleanupNetworking(); } } /* renamed from: c */ public abstract void onSessionStart(); /* renamed from: d */ public abstract void onRoundStart(); /* renamed from: e */ public abstract void onSessionEnd(); /* renamed from: f */ public void cleanupNetworking() { if (this.sessionType != 1) { if (this.sessionType == 2) { BluetoothDiscoveryClient.getInstance().bluetoothControlChannel233.execute138(); } } else { BluetoothServerListener.getInstance_2().execute190(); ConnectionManager c0035dM216a = ConnectionManager.getInstance_2(); if (c0035dM216a != null) { c0035dM216a.sendPacket223(); ConnectionManager.execute217(); } } } }