Sunbit v2.4.4版本的 MD5 值为:a5021e5e2a58eb1d6741b432fe7533c4
以下内容为反编译后的 a.java 源代码,内容仅作参考
package q.c;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
public abstract class a extends g {
private boolean c;
private boolean f22371d;
private ScheduledExecutorService f22372e;
private ScheduledFuture f22373f;
private final q.j.c b = q.j.d.a(a.class);
private long f22374g = TimeUnit.SECONDS.toNanos(60);
private boolean f22375h = false;
private final Object f22376i = new Object();
public class RunnableC0586a implements Runnable {
private ArrayList<f> f22377a = new ArrayList<>();
RunnableC0586a() {
}
@Override
public void run() {
this.f22377a.clear();
try {
this.f22377a.addAll(a.this.m());
long nanoTime = (long) (System.nanoTime() - (a.this.f22374g * 1.5d));
Iterator<f> it = this.f22377a.iterator();
while (it.hasNext()) {
a.this.a(it.next(), nanoTime);
}
} catch (Exception unused) {
}
this.f22377a.clear();
}
}
private void r() {
ScheduledExecutorService scheduledExecutorService = this.f22372e;
if (scheduledExecutorService != null) {
scheduledExecutorService.shutdownNow();
this.f22372e = null;
}
ScheduledFuture scheduledFuture = this.f22373f;
if (scheduledFuture != null) {
scheduledFuture.cancel(false);
this.f22373f = null;
}
}
private void s() {
r();
this.f22372e = Executors.newSingleThreadScheduledExecutor(new q.c.w.d("connectionLostChecker"));
RunnableC0586a runnableC0586a = new RunnableC0586a();
ScheduledExecutorService scheduledExecutorService = this.f22372e;
long j2 = this.f22374g;
this.f22373f = scheduledExecutorService.scheduleAtFixedRate(runnableC0586a, j2, j2, TimeUnit.NANOSECONDS);
}
public void b(int i2) {
synchronized (this.f22376i) {
long nanos = TimeUnit.SECONDS.toNanos(i2);
this.f22374g = nanos;
if (nanos <= 0) {
this.b.e("Connection lost timer stopped");
r();
return;
}
if (this.f22375h) {
this.b.e("Connection lost timer restarted");
try {
Iterator it = new ArrayList(m()).iterator();
while (it.hasNext()) {
f fVar = (f) it.next();
if (fVar instanceof i) {
((i) fVar).s();
}
}
} catch (Exception e2) {
this.b.d("Exception during connection lost restart", e2);
}
s();
}
}
}
public int l() {
int seconds;
synchronized (this.f22376i) {
seconds = (int) TimeUnit.NANOSECONDS.toSeconds(this.f22374g);
}
return seconds;
}
protected abstract Collection<f> m();
public boolean n() {
return this.f22371d;
}
public boolean o() {
return this.c;
}
public void p() {
synchronized (this.f22376i) {
if (this.f22374g <= 0) {
this.b.e("Connection lost timer deactivated");
return;
}
this.b.e("Connection lost timer started");
this.f22375h = true;
s();
}
}
public void q() {
synchronized (this.f22376i) {
if (this.f22372e != null || this.f22373f != null) {
this.f22375h = false;
this.b.e("Connection lost timer stopped");
r();
}
}
}
public void a(f fVar, long j2) {
if (fVar instanceof i) {
i iVar = (i) fVar;
if (iVar.o() < j2) {
this.b.c("Closing connection due to no pong received: {}", iVar);
iVar.b(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");
} else if (iVar.isOpen()) {
iVar.h();
} else {
this.b.c("Trying to ping a non open connection: {}", iVar);
}
}
}
public void a(boolean z) {
this.f22371d = z;
}
public void b(boolean z) {
this.c = z;
}
}