package ul1; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.Timer; import java.util.TimerTask; import org.java_websocket.WebSocket; import org.slf4j.Logger; import p4.h; import yl1.g; /* compiled from: AbstractWebSocket */ public abstract class a extends b { private static final Logger log = rm1.a.d(a.class); public boolean b; /* renamed from: c reason: collision with root package name */ public boolean f39015c; public Timer d; public TimerTask e; public final Object f = new Object(); /* renamed from: ul1.a$a reason: collision with other inner class name */ /* compiled from: AbstractWebSocket */ public class C0686a extends TimerTask { public ArrayList<WebSocket> b = new ArrayList<>(); public C0686a() { } public void run() { this.b.clear(); try { this.b.addAll(a.this.b()); long currentTimeMillis = System.currentTimeMillis() - ((long) 90000); Iterator<WebSocket> it2 = this.b.iterator(); while (it2.hasNext()) { a.this.a(it2.next(), currentTimeMillis); } } catch (Exception unused) { } this.b.clear(); } } public void a(WebSocket webSocket, long j) { if (webSocket instanceof c) { c cVar = (c) webSocket; if (cVar.n < j) { log.trace("Closing connection due to no pong received: {}", cVar); cVar.c(1006, "The connection was closed because the other endpoint did not respond with a pong in time. For more information check: https://github.com/TooTallNate/Java-WebSocket/wiki/Lost-connection-detection", false); } else if (cVar.isOpen()) { if (cVar.p == null) { cVar.p = new g(); } cVar.sendFrame(cVar.p); } else { log.trace("Trying to ping a non open connection: {}", cVar); } } } public abstract Collection<WebSocket> b(); public final void c() { Timer timer = this.d; if (timer != null) { timer.cancel(); this.d = null; } TimerTask timerTask = this.e; if (timerTask != null) { timerTask.cancel(); this.e = null; } this.d = new h("WebSocketTimer", "org.java_websocket.AbstractWebSocket"); C0686a aVar = new C0686a(); this.e = aVar; long j = ((long) 60) * 1000; this.d.scheduleAtFixedRate(aVar, j, j); } public void d() { synchronized (this.f) { log.trace("Connection lost timer started"); c(); } } public void e() { synchronized (this.f) { if (!(this.d == null && this.e == null)) { log.trace("Connection lost timer stopped"); Timer timer = this.d; if (timer != null) { timer.cancel(); this.d = null; } TimerTask timerTask = this.e; if (timerTask != null) { timerTask.cancel(); this.e = null; } } } } }