discord-jadx/app/src/main/java/c/a/r/l0/a.java

815 lines
32 KiB
Java

package c.a.r.l0;
import android.os.Handler;
import android.os.Looper;
import android.os.Process;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.discord.rtcconnection.socket.io.Opcodes;
import com.discord.rtcconnection.socket.io.Payloads;
import com.discord.utilities.debug.DebugPrintBuilder;
import com.discord.utilities.debug.DebugPrintable;
import com.discord.utilities.logging.Logger;
import com.discord.utilities.networking.Backoff;
import com.discord.utilities.time.Clock;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.reflect.TypeToken;
import d0.z.d.m;
import d0.z.d.o;
import f0.f0.k.h;
import f0.x;
import f0.z;
import java.lang.reflect.Type;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.CopyOnWriteArraySet;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLSocketFactory;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import okhttp3.Response;
import okhttp3.WebSocket;
import okhttp3.WebSocketListener;
/* compiled from: RtcControlSocket.kt */
public final class a extends WebSocketListener implements DebugPrintable {
public static int i;
public static final Type j = new C0038a().getType();
public static final b k = new b(null);
public boolean A;
public final String B;
public final String C;
public final String D;
public final SSLSocketFactory E;
public final Logger F;
public final c.a.r.c G;
public final Clock H;
public final String I;
public final Gson l = new c.i.d.e().a();
public final Timer m = new Timer();
public final Backoff n = new Backoff(1000, 5000, 3, false, null, 24, null);
public final CopyOnWriteArraySet<d> o = new CopyOnWriteArraySet<>();
public int p = 3;
public WebSocket q;
public String r;
/* renamed from: s reason: collision with root package name */
public String f213s;
public Long t;
public boolean u;
public b v = new b(this);
public Long w;
/* renamed from: x reason: collision with root package name */
public TimerTask f214x;
/* renamed from: y reason: collision with root package name */
public Long f215y;
/* renamed from: z reason: collision with root package name */
public c f216z = c.DISCONNECTED;
/* compiled from: RtcControlSocket.kt */
/* renamed from: c.a.r.l0.a$a reason: collision with other inner class name */
public static final class C0038a extends TypeToken<Map<String, ? extends Integer>> {
}
/* compiled from: RtcControlSocket.kt */
public static final class b {
public b(DefaultConstructorMarker defaultConstructorMarker) {
}
}
/* compiled from: RtcControlSocket.kt */
public enum c {
DISCONNECTED,
CONNECTING,
IDENTIFYING,
RESUMING,
CONNECTED,
RECONNECTING
}
/* compiled from: RtcControlSocket.kt */
public interface d {
void a(String str, String str2);
void b(boolean z2, Integer num, String str);
void c(String str, List<Integer> list);
void d(String str);
void e(long j, int i, int i2, List<Payloads.Stream> list);
void f(Map<String, Integer> map);
void g(long j);
void h();
void i();
void j();
void k(long j);
void l(int i, int i2, String str);
void onSpeaking(long j, int i, boolean z2);
}
/* compiled from: RtcControlSocket.kt */
public static final class e extends o implements Function1<WebSocket, Unit> {
public static final e i = new e();
public e() {
super(1);
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // kotlin.jvm.functions.Function1
public Unit invoke(WebSocket webSocket) {
WebSocket webSocket2 = webSocket;
m.checkNotNullParameter(webSocket2, "it");
webSocket2.e(1000, "Force Close");
return Unit.a;
}
}
/* compiled from: RtcControlSocket.kt */
public static final class f extends o implements Function1<WebSocket, Unit> {
public static final f i = new f();
public f() {
super(1);
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // kotlin.jvm.functions.Function1
public Unit invoke(WebSocket webSocket) {
WebSocket webSocket2 = webSocket;
m.checkNotNullParameter(webSocket2, "it");
webSocket2.e(4000, "close reason");
return Unit.a;
}
}
/* compiled from: RtcControlSocket.kt */
public static final class g extends TimerTask {
public final /* synthetic */ a i;
/* compiled from: RtcControlSocket.kt */
/* renamed from: c.a.r.l0.a$g$a reason: collision with other inner class name */
public static final class C0039a extends o implements Function0<Unit> {
public final /* synthetic */ g this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public C0039a(g gVar) {
super(0);
this.this$0 = gVar;
}
/* Return type fixed from 'java.lang.Object' to match base method */
@Override // kotlin.jvm.functions.Function0
/* renamed from: invoke */
public Unit mo1invoke() {
a.a(this.this$0.i, true, null, "The connection timed out. Did not receive OP_HELLO in time.");
return Unit.a;
}
}
public g(a aVar) {
this.i = aVar;
}
@Override // java.util.TimerTask, java.lang.Runnable
public void run() {
this.i.n(new C0039a(this));
}
}
/* compiled from: RtcControlSocket.kt */
public static final class h extends o implements Function0<Unit> {
public final /* synthetic */ int $code;
public final /* synthetic */ String $reason;
public final /* synthetic */ WebSocket $webSocket;
public final /* synthetic */ a this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public h(a aVar, WebSocket webSocket, int i, String str) {
super(0);
this.this$0 = aVar;
this.$webSocket = webSocket;
this.$code = i;
this.$reason = str;
}
/* Return type fixed from 'java.lang.Object' to match base method */
@Override // kotlin.jvm.functions.Function0
/* renamed from: invoke */
public Unit mo1invoke() {
if (!(!m.areEqual(this.$webSocket, this.this$0.q))) {
a.a(this.this$0, true, Integer.valueOf(this.$code), this.$reason);
}
return Unit.a;
}
}
/* compiled from: RtcControlSocket.kt */
public static final class i extends o implements Function0<Unit> {
public final /* synthetic */ Throwable $t;
public final /* synthetic */ WebSocket $webSocket;
public final /* synthetic */ a this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public i(a aVar, WebSocket webSocket, Throwable th) {
super(0);
this.this$0 = aVar;
this.$webSocket = webSocket;
this.$t = th;
}
/* Return type fixed from 'java.lang.Object' to match base method */
@Override // kotlin.jvm.functions.Function0
/* renamed from: invoke */
public Unit mo1invoke() {
if (!(!m.areEqual(this.$webSocket, this.this$0.q))) {
if (this.$t instanceof SSLException) {
a.d(this.this$0, null, 1);
a aVar = this.this$0;
aVar.b();
for (d dVar : aVar.o) {
m.checkNotNullExpressionValue(dVar, "it");
dVar.b(false, 1001, null);
}
} else {
a aVar2 = this.this$0;
StringBuilder L = c.d.b.a.a.L("An error with the websocket occurred: ");
L.append(this.$t.getMessage());
a.a(aVar2, true, null, L.toString());
}
}
return Unit.a;
}
}
/* compiled from: RtcControlSocket.kt */
public static final class j extends o implements Function0<Unit> {
public final /* synthetic */ Payloads.Incoming $message;
public final /* synthetic */ WebSocket $webSocket;
public final /* synthetic */ a this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public j(a aVar, WebSocket webSocket, Payloads.Incoming incoming) {
super(0);
this.this$0 = aVar;
this.$webSocket = webSocket;
this.$message = incoming;
}
/* Return type fixed from 'java.lang.Object' to match base method */
@Override // kotlin.jvm.functions.Function0
/* renamed from: invoke */
public Unit mo1invoke() {
boolean z2 = true;
if (!(!m.areEqual(this.$webSocket, this.this$0.q))) {
switch (this.$message.getOpcode()) {
case 2:
a aVar = this.this$0;
Object c2 = aVar.l.c(this.$message.getData(), Payloads.Ready.class);
m.checkNotNullExpressionValue(c2, "gson.fromJson(message.da…yloads.Ready::class.java)");
Payloads.Ready ready = (Payloads.Ready) c2;
aVar.n.succeed();
long currentTimeMillis = aVar.H.currentTimeMillis();
Long l = aVar.f215y;
long longValue = currentTimeMillis - (l != null ? l.longValue() : 0);
aVar.j("[READY] took " + longValue + " ms");
aVar.b();
for (d dVar : aVar.o) {
m.checkNotNullExpressionValue(dVar, "it");
dVar.l(ready.getPort(), ready.getSsrc(), ready.getIp());
}
break;
case 3:
a aVar2 = this.this$0;
aVar2.o(3, String.valueOf(aVar2.H.currentTimeMillis()));
break;
case 4:
a aVar3 = this.this$0;
Object c3 = aVar3.l.c(this.$message.getData(), Payloads.Description.class);
m.checkNotNullExpressionValue(c3, "gson.fromJson(message.da….Description::class.java)");
Payloads.Description description = (Payloads.Description) c3;
aVar3.b();
for (d dVar2 : aVar3.o) {
m.checkNotNullExpressionValue(dVar2, "it");
dVar2.c(description.getMode(), description.getSecretKey());
dVar2.a(description.getAudioCodec(), description.getVideoCodec());
String mediaSessionId = description.getMediaSessionId();
if (mediaSessionId != null) {
dVar2.d(mediaSessionId);
}
}
aVar3.A = true;
break;
case 5:
a aVar4 = this.this$0;
Object c4 = aVar4.l.c(this.$message.getData(), Payloads.Speaking.class);
m.checkNotNullExpressionValue(c4, "gson.fromJson(message.da…ads.Speaking::class.java)");
Payloads.Speaking speaking = (Payloads.Speaking) c4;
if (!(speaking.getUserId() == null || speaking.getSpeaking() == null)) {
Integer speaking2 = speaking.getSpeaking();
if (speaking2 == null || speaking2.intValue() != 1) {
z2 = false;
}
aVar4.b();
for (d dVar3 : aVar4.o) {
m.checkNotNullExpressionValue(dVar3, "it");
dVar3.onSpeaking(speaking.getUserId().longValue(), speaking.getSsrc(), z2);
}
break;
}
case 6:
a aVar5 = this.this$0;
Object c5 = aVar5.l.c(this.$message.getData(), Long.TYPE);
m.checkNotNullExpressionValue(c5, "gson.fromJson(message.data, Long::class.java)");
long longValue2 = ((Number) c5).longValue();
long currentTimeMillis2 = aVar5.H.currentTimeMillis();
long j = currentTimeMillis2 - longValue2;
Logger.d$default(aVar5.F, aVar5.B, c.d.b.a.a.r("got heartbeat ack after ", j, " ms"), null, 4, null);
aVar5.w = Long.valueOf(currentTimeMillis2);
aVar5.u = true;
aVar5.b();
for (d dVar4 : aVar5.o) {
m.checkNotNullExpressionValue(dVar4, "it");
dVar4.g(j);
}
break;
case 7:
case 10:
case 11:
default:
a aVar6 = this.this$0;
StringBuilder L = c.d.b.a.a.L("unknown opcode: ");
L.append(this.$message.getOpcode());
aVar6.j(L.toString());
break;
case 8:
a aVar7 = this.this$0;
Object c6 = aVar7.l.c(this.$message.getData(), Payloads.Hello.class);
m.checkNotNullExpressionValue(c6, "gson.fromJson(message.da…yloads.Hello::class.java)");
Payloads.Hello hello = (Payloads.Hello) c6;
TimerTask timerTask = aVar7.f214x;
if (timerTask != null) {
timerTask.cancel();
}
aVar7.j("[HELLO] raw: " + hello);
aVar7.t = Long.valueOf(hello.getHeartbeatIntervalMs());
aVar7.p = hello.getServerVersion();
aVar7.v.cancel();
aVar7.u = true;
aVar7.l();
break;
case 9:
this.this$0.n.succeed();
break;
case 12:
a aVar8 = this.this$0;
Object c7 = aVar8.l.c(this.$message.getData(), Payloads.Video.class);
m.checkNotNullExpressionValue(c7, "gson.fromJson(message.da…yloads.Video::class.java)");
Payloads.Video video = (Payloads.Video) c7;
if (video.getUserId() != null) {
aVar8.b();
for (d dVar5 : aVar8.o) {
m.checkNotNullExpressionValue(dVar5, "it");
dVar5.e(video.getUserId().longValue(), video.getAudioSsrc(), video.getVideoSsrc(), video.getStreams());
}
break;
}
break;
case 13:
a aVar9 = this.this$0;
Object c8 = aVar9.l.c(this.$message.getData(), Payloads.ClientDisconnect.class);
m.checkNotNullExpressionValue(c8, "gson.fromJson(message.da…ntDisconnect::class.java)");
Payloads.ClientDisconnect clientDisconnect = (Payloads.ClientDisconnect) c8;
aVar9.b();
for (d dVar6 : aVar9.o) {
m.checkNotNullExpressionValue(dVar6, "it");
dVar6.k(clientDisconnect.getUserId());
}
break;
case 14:
a aVar10 = this.this$0;
Object c9 = aVar10.l.c(this.$message.getData(), Payloads.SessionUpdate.class);
m.checkNotNullExpressionValue(c9, "gson.fromJson(message.da…essionUpdate::class.java)");
Payloads.SessionUpdate sessionUpdate = (Payloads.SessionUpdate) c9;
aVar10.b();
for (d dVar7 : aVar10.o) {
m.checkNotNullExpressionValue(dVar7, "it");
String mediaSessionId2 = sessionUpdate.getMediaSessionId();
if (mediaSessionId2 != null) {
dVar7.d(mediaSessionId2);
}
}
break;
case 15:
a aVar11 = this.this$0;
Gson gson = aVar11.l;
JsonElement data = this.$message.getData();
Type type = a.j;
Objects.requireNonNull(gson);
Object d = data == null ? null : gson.d(new c.i.d.q.x.a(data), type);
m.checkNotNullExpressionValue(d, "gson.fromJson(message.data, MEDIA_SINK_WANTS_TYPE)");
Map<String, Integer> map = (Map) d;
aVar11.b();
for (d dVar8 : aVar11.o) {
m.checkNotNullExpressionValue(dVar8, "it");
dVar8.f(map);
}
break;
}
}
return Unit.a;
}
}
/* compiled from: RtcControlSocket.kt */
public static final class k extends o implements Function0<Unit> {
public final /* synthetic */ WebSocket $webSocket;
public final /* synthetic */ a this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public k(a aVar, WebSocket webSocket) {
super(0);
this.this$0 = aVar;
this.$webSocket = webSocket;
}
/* Return type fixed from 'java.lang.Object' to match base method */
@Override // kotlin.jvm.functions.Function0
/* renamed from: invoke */
public Unit mo1invoke() {
boolean z2 = true;
if (!(!m.areEqual(this.$webSocket, this.this$0.q))) {
a aVar = this.this$0;
c cVar = aVar.f216z;
if (cVar == c.CONNECTING) {
aVar.b();
for (d dVar : aVar.o) {
m.checkNotNullExpressionValue(dVar, "it");
dVar.j();
}
} else if (cVar == c.RECONNECTING) {
String str = aVar.f213s;
String str2 = aVar.r;
String str3 = aVar.D;
Long l = aVar.w;
if (l != null && aVar.H.currentTimeMillis() - l.longValue() > 60000) {
z2 = false;
}
if (str == null || str2 == null || !aVar.A || !z2) {
StringBuilder L = c.d.b.a.a.L("Cannot resume connection. resumable: ");
L.append(aVar.A);
L.append(" -- isHeartbeatRecentEnough: ");
L.append(z2);
aVar.h(false, 4801, L.toString());
} else {
aVar.j("[RESUME] resuming session. serverId=" + str2 + " sessionId=" + str);
aVar.b();
for (d dVar2 : aVar.o) {
m.checkNotNullExpressionValue(dVar2, "it");
dVar2.h();
}
aVar.f216z = c.RESUMING;
aVar.o(7, new Payloads.Resume(str3, str, str2));
}
}
a aVar2 = this.this$0;
aVar2.f216z = c.CONNECTED;
long currentTimeMillis = aVar2.H.currentTimeMillis();
Long l2 = this.this$0.f215y;
long longValue = currentTimeMillis - (l2 != null ? l2.longValue() : 0);
a aVar3 = this.this$0;
Logger logger = aVar3.F;
String str4 = aVar3.B;
StringBuilder L2 = c.d.b.a.a.L("[CONNECTED] to ");
L2.append(this.this$0.C);
Logger.i$default(logger, str4, L2.toString(), null, 4, null);
a aVar4 = this.this$0;
aVar4.b();
for (d dVar3 : aVar4.o) {
m.checkNotNullExpressionValue(dVar3, "it");
dVar3.g(longValue / ((long) 2));
}
}
return Unit.a;
}
}
/* compiled from: RtcControlSocket.kt */
public static final class l extends o implements Function1<WebSocket, Unit> {
public static final l i = new l();
public l() {
super(1);
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // kotlin.jvm.functions.Function1
public Unit invoke(WebSocket webSocket) {
WebSocket webSocket2 = webSocket;
m.checkNotNullParameter(webSocket2, "it");
webSocket2.e(4000, "reconnecting");
return Unit.a;
}
}
public a(String str, String str2, SSLSocketFactory sSLSocketFactory, Logger logger, c.a.r.c cVar, Clock clock, String str3) {
m.checkNotNullParameter(str, "endpoint");
m.checkNotNullParameter(str2, "token");
m.checkNotNullParameter(logger, "logger");
m.checkNotNullParameter(cVar, "mediaEngineThreadExecutor");
m.checkNotNullParameter(clock, "clock");
m.checkNotNullParameter(str3, "loggingTagPrefix");
this.C = str;
this.D = str2;
this.E = sSLSocketFactory;
this.F = logger;
this.G = cVar;
this.H = clock;
this.I = str3;
StringBuilder P = c.d.b.a.a.P(str3, "->RtcControlSocket ");
int i2 = i + 1;
i = i2;
P.append(i2);
this.B = P.toString();
}
public static final void a(a aVar, boolean z2, Integer num, String str) {
aVar.f216z = c.DISCONNECTED;
if ((num != null && num.intValue() == 4004) || ((num != null && num.intValue() == 4015) || ((num != null && num.intValue() == 4011) || (num != null && num.intValue() == 4006)))) {
aVar.h(true, num, str);
} else if (aVar.n.hasReachedFailureThreshold()) {
aVar.k("[WS CLOSED] Backoff exceeded. Resetting.");
aVar.h(z2, num, str);
} else {
aVar.c(null);
String H = c.d.b.a.a.H(new Object[]{Double.valueOf(((double) aVar.n.fail(new c(aVar, z2, num, str))) / 1000.0d)}, 1, "%.2f", "java.lang.String.format(this, *args)");
aVar.k("`[WS CLOSED] (" + z2 + ", " + num + ", " + str + ") retrying in " + H + " seconds.");
}
}
public static /* synthetic */ void d(a aVar, Function1 function1, int i2) {
int i3 = i2 & 1;
aVar.c(null);
}
public final void b() {
c.a.r.c cVar = this.G;
Objects.requireNonNull(cVar);
if (Process.myTid() != cVar.j) {
IllegalStateException illegalStateException = new IllegalStateException("oops! not called on the MediaEngineExecutor");
AnimatableValueParser.D1("MediaEngineExecutor", "oops! not called on the MediaEngineExecutor", illegalStateException);
if (cVar.l) {
new Handler(Looper.getMainLooper()).post(new c.a.r.d(illegalStateException));
}
}
}
public final void c(Function1<? super WebSocket, Unit> function1) {
this.n.cancel();
this.v.cancel();
TimerTask timerTask = this.f214x;
if (timerTask != null) {
timerTask.cancel();
}
WebSocket webSocket = this.q;
if (!(webSocket == null || function1 == null)) {
function1.invoke(webSocket);
}
this.q = null;
}
@Override // com.discord.utilities.debug.DebugPrintable
public void debugPrint(DebugPrintBuilder debugPrintBuilder) {
m.checkNotNullParameter(debugPrintBuilder, "dp");
debugPrintBuilder.appendKeyValue("serverId", this.r);
debugPrintBuilder.appendKeyValue("sessionId", this.f213s);
debugPrintBuilder.appendKeyValue("heartbeatInterval", this.t);
debugPrintBuilder.appendKeyValue("lastHeartbeatAckTime", this.w);
debugPrintBuilder.appendKeyValue("connectionStartTime", this.f215y);
debugPrintBuilder.appendKeyValue("connectionState", this.f216z);
debugPrintBuilder.appendKeyValue("resumable", Boolean.valueOf(this.A));
}
public final void e() {
b();
j("[CLOSE]");
c(e.i);
this.r = null;
this.f213s = null;
this.A = false;
this.f216z = c.DISCONNECTED;
b();
for (d dVar : this.o) {
m.checkNotNullExpressionValue(dVar, "it");
dVar.b(false, 1000, "Force Close");
}
}
public final boolean f() {
b();
if (this.f216z != c.DISCONNECTED) {
k("Cannot start a new connection, connection state is not disconnected");
return false;
}
this.f216z = c.CONNECTING;
g();
b();
for (d dVar : this.o) {
m.checkNotNullExpressionValue(dVar, "it");
dVar.i();
}
return true;
}
public final void g() {
StringBuilder L = c.d.b.a.a.L("[CONNECT] ");
L.append(this.C);
j(L.toString());
if (this.q != null) {
this.F.e(this.B, "Connect called with already existing websocket", null, null);
c(f.i);
return;
}
this.f215y = Long.valueOf(this.H.currentTimeMillis());
TimerTask timerTask = this.f214x;
if (timerTask != null) {
timerTask.cancel();
}
g gVar = new g(this);
this.f214x = gVar;
this.m.schedule(gVar, 20000);
x.a aVar = new x.a();
aVar.a(1, TimeUnit.MINUTES);
SSLSocketFactory sSLSocketFactory = this.E;
if (sSLSocketFactory != null) {
h.a aVar2 = f0.f0.k.h.f2737c;
aVar.b(sSLSocketFactory, f0.f0.k.h.a.n());
}
String D = c.d.b.a.a.D(new StringBuilder(), this.C, "?v=5");
j("attempting WSS connection with " + D);
x xVar = new x(aVar);
z.a aVar3 = new z.a();
aVar3.f(D);
this.q = xVar.g(aVar3.a(), this);
}
public final void h(boolean z2, Integer num, String str) {
k("[DISCONNECT] (" + z2 + ", " + num + ", " + str + ')');
c(null);
this.r = null;
this.f213s = null;
this.A = false;
this.f216z = c.DISCONNECTED;
b();
for (d dVar : this.o) {
m.checkNotNullExpressionValue(dVar, "it");
dVar.b(z2, num, str);
}
}
public final void i(long j2, String str, boolean z2) {
m.checkNotNullParameter(str, "reason");
b();
if (this.q != null) {
j("Performing an immediate heartbeat on existing socket: " + str);
this.v.cancel();
b bVar = new b(this);
this.v = bVar;
this.m.schedule(bVar, j2);
} else if (!z2) {
j("Immediate heartbeat requested, but is disconnected and a reset was not requested: " + str);
} else if (this.n.isPending() && this.q == null) {
j("Connection backoff reset Immediate heartbeat when socket was disconnected.");
this.n.succeed();
m(false, 4802, "Reset backoff.");
}
}
public final void j(String str) {
Logger.i$default(this.F, this.B, str, null, 4, null);
}
public final void k(String str) {
Logger.w$default(this.F, this.B, str, null, 4, null);
}
public final void l() {
if (this.u) {
this.u = false;
o(3, String.valueOf(this.H.currentTimeMillis()));
Long l2 = this.t;
if (l2 != null) {
b bVar = new b(this);
this.v = bVar;
this.m.schedule(bVar, l2.longValue());
return;
}
k("onHeartbeatInterval called when heartbeatInterval was null");
return;
}
c(d.i);
String H = c.d.b.a.a.H(new Object[]{Double.valueOf(((double) this.n.fail(new e(this))) / 1000.0d)}, 1, "%.2f", "java.lang.String.format(this, *args)");
k("[ACK TIMEOUT] reconnecting in " + H + " seconds.");
}
public final void m(boolean z2, Integer num, String str) {
j("[RECONNECT] wasFatal=" + z2 + " code=" + num + " reason=" + str);
c(l.i);
this.f216z = c.RECONNECTING;
g();
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARNING: Unknown variable types count: 1 */
public final Future<?> n(Function0<Unit> function0) {
c.a.r.c cVar = this.G;
if (function0 != null) {
function0 = new f(function0);
}
return cVar.submit((Runnable) function0);
}
public final void o(int i2, Object obj) {
WebSocket webSocket = this.q;
if (webSocket == null) {
StringBuilder L = c.d.b.a.a.L("opcode() websocket null. opcode: ");
L.append(Opcodes.INSTANCE.getNameOf(i2));
this.F.e(this.B, L.toString(), null, null);
return;
}
try {
String m = this.l.m(new Payloads.Outgoing(i2, obj));
Logger logger = this.F;
String str = this.B;
Logger.d$default(logger, str, "sending (" + Opcodes.INSTANCE.getNameOf(i2) + "): " + m, null, 4, null);
m.checkNotNullExpressionValue(m, "json");
webSocket.a(m);
} catch (Exception unused) {
Logger logger2 = this.F;
String str2 = this.B;
Logger.w$default(logger2, str2, "exception sending opcode: " + i2 + " and payload: " + obj, null, 4, null);
}
}
@Override // okhttp3.WebSocketListener
public void onClosed(WebSocket webSocket, int i2, String str) {
m.checkNotNullParameter(webSocket, "webSocket");
m.checkNotNullParameter(str, "reason");
super.onClosed(webSocket, i2, str);
n(new h(this, webSocket, i2, str));
}
@Override // okhttp3.WebSocketListener
public void onClosing(WebSocket webSocket, int i2, String str) {
m.checkNotNullParameter(webSocket, "webSocket");
m.checkNotNullParameter(str, "reason");
((f0.f0.n.d) webSocket).e(i2, str);
}
@Override // okhttp3.WebSocketListener
public void onFailure(WebSocket webSocket, Throwable th, Response response) {
m.checkNotNullParameter(webSocket, "webSocket");
m.checkNotNullParameter(th, "t");
super.onFailure(webSocket, th, response);
n(new i(this, webSocket, th));
}
@Override // okhttp3.WebSocketListener
public void onMessage(WebSocket webSocket, String str) {
m.checkNotNullParameter(webSocket, "webSocket");
m.checkNotNullParameter(str, "text");
Object g2 = this.l.g(str, Payloads.Incoming.class);
super.onMessage(webSocket, str);
n(new j(this, webSocket, (Payloads.Incoming) c.i.a.f.e.o.c.q0(Payloads.Incoming.class).cast(g2)));
}
@Override // okhttp3.WebSocketListener
public void onOpen(WebSocket webSocket, Response response) {
m.checkNotNullParameter(webSocket, "webSocket");
m.checkNotNullParameter(response, "response");
super.onOpen(webSocket, response);
n(new k(this, webSocket));
}
}