Warkop v5.73.0版本的 MD5 值为:a4330ec2d6f5e146f59fc7622f3cdb45

以下内容为反编译后的 l.java 源代码,内容仅作参考


package xj;

import com.voximplant.sdk.internal.proto.i1;
import com.voximplant.sdk.internal.proto.k0;
import com.voximplant.sdk.internal.proto.l0;
import com.voximplant.sdk.internal.proto.o0;
import com.voximplant.sdk.internal.proto.p0;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import ns.b0;
import xj.l;
import yj.s0;

public class l implements ck.g {

    private final ck.s f174805a;

    private final com.voximplant.sdk.internal.utils.b f174806b;

    private m f174807c;

    private g0 f174808d;

    private ScheduledFuture<?> f174809e;

    private ScheduledFuture<?> f174810f;

    private ScheduledFuture<?> f174811g;

    private ScheduledFuture<?> f174812h;

    private boolean f174813i;

    private final s0 f174814j;

    private List<String> f174815k;

    private boolean f174816l;

    private boolean f174817m;

    private boolean f174818n;

    private boolean f174819o;

    public class a implements ns.f {

        final String f174820c;

        a(String str) {
            this.f174820c = str;
        }

        public void d(String str, IOException iOException) {
            if (!l.this.f174816l && l.this.f174807c != m.DISCONNECTED) {
                if (l.this.f174809e != null) {
                    l.this.f174809e.cancel(true);
                    l.this.f174809e = null;
                }
                l.this.f174818n = false;
                i0.c(l.this.C() + "request to balancer (" + str + ") is failed:" + iOException);
                l.this.T("http request is failed");
                return;
            }
            i0.j(l.this.C() + "onFailure while disconnecting or in disconnected state, ignoring");
        }

        public void e() {
            l.this.f174818n = false;
            if (l.this.f174817m && !l.this.f174816l) {
                l.this.V();
            }
        }

        public void f(ns.d0 d0Var, String str) {
            String str2;
            i0.d(l.this.C() + "onResponse");
            if (!l.this.f174816l && l.this.f174807c != m.DISCONNECTED) {
                if (l.this.f174809e != null) {
                    l.this.f174809e.cancel(true);
                    l.this.f174809e = null;
                }
                if (!d0Var.isSuccessful()) {
                    i0.c(l.this.C() + "Unexpected code: " + d0Var);
                    if (d0Var.getCode() >= 500 && d0Var.getCode() < 600) {
                        l.this.f174818n = true;
                        l.this.f174817m = false;
                        if (l.this.f174811g != null) {
                            l.this.f174811g.cancel(true);
                        }
                        l lVar = l.this;
                        lVar.f174811g = lVar.f174806b.c(new Runnable() {
                            @Override
                            public final void run() {
                                l.a.this.e();
                            }
                        }, 5000);
                    }
                    if (d0Var.getMessage() != null && !d0Var.getMessage().isEmpty()) {
                        str2 = d0Var.getMessage() + "(" + str + ")";
                    } else {
                        str2 = "Server is unavailable (" + str + ")";
                    }
                    l.this.T(str2);
                    return;
                }
                if (d0Var.getCode() == 200) {
                    i0.d(l.this.C() + "onResponse: response code is successful");
                    try {
                        ns.e0 body = d0Var.getBody();
                        if (body != null) {
                            l.this.f174815k = Arrays.asList(body.s2().split(";"));
                            i0.d("onResponse: servers: " + l.this.f174815k);
                            l.this.X();
                        } else {
                            d0Var.close();
                            i0.c(l.this.C() + "Failed to get servers, response is empty(" + str + ")");
                            l.this.T("Not able to connect to any servers");
                        }
                        return;
                    } catch (IOException unused) {
                        i0.c(l.this.C() + "Failed to get servers(" + str + ")");
                        l.this.T("Not able to connect to any servers");
                        return;
                    }
                }
                i0.c(l.this.C() + "onResponse: response code is not successful (" + str + ")");
                l.this.T(d0Var.getMessage());
                return;
            }
            i0.j(l.this.C() + "onResponse while disconnecting or in disconnected state, ignoring");
        }

        @Override
        public void onFailure(ns.e eVar, final IOException iOException) {
            com.voximplant.sdk.internal.utils.b bVar = l.this.f174806b;
            final String str = this.f174820c;
            bVar.b(new Runnable() {
                @Override
                public final void run() {
                    l.a.this.d(str, iOException);
                }
            });
        }

        @Override
        public void onResponse(ns.e eVar, final ns.d0 d0Var) {
            com.voximplant.sdk.internal.utils.b bVar = l.this.f174806b;
            final String str = this.f174820c;
            bVar.b(new Runnable() {
                @Override
                public final void run() {
                    l.a.this.f(d0Var, str);
                }
            });
        }
    }

    public l(s0 s0Var) {
        ck.s u15 = ck.s.u();
        this.f174805a = u15;
        this.f174806b = com.voximplant.sdk.internal.utils.b.a();
        this.f174809e = null;
        this.f174810f = null;
        this.f174811g = null;
        this.f174812h = null;
        this.f174816l = false;
        this.f174817m = false;
        this.f174818n = false;
        this.f174807c = m.DISCONNECTED;
        this.f174814j = s0Var;
        u15.r(this);
    }

    public String C() {
        return "Authenticator [" + this.f174807c + "] ";
    }

    private void F() {
        this.f174818n = true;
        ScheduledFuture<?> scheduledFuture = this.f174811g;
        if (scheduledFuture != null) {
            scheduledFuture.cancel(true);
        }
        this.f174811g = this.f174806b.c(new Runnable() {
            @Override
            public final void run() {
                l.this.H();
            }
        }, 5000);
    }

    public void H() {
        this.f174818n = false;
    }

    public void I() {
        i0.c(C() + "loginWithOneTimeKey: failed due to timeout");
        this.f174807c = m.CONNECTED;
        this.f174808d.l(null, 408);
    }

    public void J(String str, String str2, Map map) {
        this.f174805a.K(new l0(str, str2, map));
    }

    public void K() {
        i0.c(C() + "loginWithToken: failed due to timeout");
        this.f174807c = m.CONNECTED;
        this.f174808d.l(null, 408);
    }

    public void L(String str, Map map) {
        this.f174805a.K(new com.voximplant.sdk.internal.proto.h0(str, "", map));
    }

    public void M(String str, Map map) {
        this.f174805a.K(new o0(str, map));
    }

    public void N(String str) {
        this.f174805a.K(new com.voximplant.sdk.internal.proto.j0(str));
    }

    public void O(String str) {
        T("Connect timeout reached(" + str + ")");
    }

    public void T(String str) {
        i0.j(C() + "reportFailure: " + str);
        this.f174807c = m.DISCONNECTED;
        ScheduledFuture<?> scheduledFuture = this.f174809e;
        if (scheduledFuture != null) {
            scheduledFuture.cancel(true);
            this.f174809e = null;
        }
        g0 g0Var = this.f174808d;
        if (g0Var != null) {
            g0Var.k(str);
        }
    }

    public void V() {
        this.f174807c = m.REQUEST_TO_BALANCER;
        final String uuid = UUID.randomUUID().toString();
        i0.d(C() + uuid);
        try {
            this.f174809e = this.f174806b.c(new Runnable() {
                @Override
                public final void run() {
                    l.this.O(uuid);
                }
            }, 30000);
            this.f174805a.G(new b0.a().v("https://balancer.voximplant.com/getNearestHost?request_uuid=" + uuid).b(), new a(uuid));
        } catch (Exception e15) {
            i0.c(C() + "requestToBalancer: exception:" + e15);
            T("request to balancer is failed");
        }
    }

    public void X() {
        this.f174807c = m.CONNECTING;
        List<String> list = this.f174815k;
        if (list != null && !list.isEmpty()) {
            this.f174805a.I(this.f174813i, this.f174815k, this.f174819o, this.f174814j);
            return;
        }
        T("Not able to connect to any servers");
        this.f174807c = m.DISCONNECTED;
        this.f174815k = null;
    }

    public void D(boolean z15, List<String> list, boolean z16) {
        if (this.f174807c != m.DISCONNECTED) {
            i0.c(C() + "connect: failed due to invalid state");
            return;
        }
        this.f174819o = z16;
        this.f174813i = z15;
        if (list != null && !list.isEmpty()) {
            this.f174815k = list;
            X();
        } else if (this.f174818n) {
            this.f174817m = true;
        } else {
            V();
        }
    }

    public void E() {
        i0.d(C() + "disconnect");
        this.f174816l = true;
        ScheduledFuture<?> scheduledFuture = this.f174809e;
        if (scheduledFuture != null) {
            scheduledFuture.cancel(true);
            this.f174809e = null;
        }
        ScheduledFuture<?> scheduledFuture2 = this.f174810f;
        if (scheduledFuture2 != null) {
            scheduledFuture2.cancel(true);
            this.f174810f = null;
        }
        ScheduledFuture<?> scheduledFuture3 = this.f174811g;
        if (scheduledFuture3 != null) {
            scheduledFuture3.cancel(true);
            this.f174811g = null;
        }
        ScheduledFuture<?> scheduledFuture4 = this.f174812h;
        if (scheduledFuture4 != null) {
            scheduledFuture4.cancel(true);
            this.f174812h = null;
        }
        this.f174817m = false;
        this.f174818n = false;
        this.f174805a.t();
    }

    public m G() {
        return this.f174807c;
    }

    public void P(final String str, final String str2, final Map<String, String> map) {
        ScheduledFuture<?> scheduledFuture;
        if (this.f174807c == m.CONNECTED) {
            this.f174810f = this.f174806b.c(new Runnable() {
                @Override
                public final void run() {
                    l.this.I();
                }
            }, 60000);
            this.f174807c = m.TRY_LOGIN;
            if (this.f174818n && (scheduledFuture = this.f174811g) != null) {
                int delay = (int) scheduledFuture.getDelay(TimeUnit.MILLISECONDS);
                if (delay > 0) {
                    i0.d(C() + "loginWithOneTimeKey: will try in " + delay + "ms (rate limit)");
                }
                com.voximplant.sdk.internal.utils.b bVar = this.f174806b;
                Runnable runnable = new Runnable() {
                    @Override
                    public final void run() {
                        l.this.J(str, str2, map);
                    }
                };
                if (delay <= 0) {
                    delay = 1;
                }
                this.f174812h = bVar.c(runnable, delay);
                return;
            }
            this.f174805a.K(new l0(str, str2, map));
            return;
        }
        i0.c(C() + "loginWithOneTimeKey: failed due to invalid state");
        this.f174808d.l(null, 491);
    }

    public void Q(final String str, final Map<String, String> map) {
        ScheduledFuture<?> scheduledFuture;
        if (this.f174807c == m.CONNECTED) {
            this.f174810f = this.f174806b.c(new Runnable() {
                @Override
                public final void run() {
                    l.this.K();
                }
            }, 60000);
            this.f174807c = m.TRY_LOGIN;
            if (this.f174818n && (scheduledFuture = this.f174811g) != null) {
                int delay = (int) scheduledFuture.getDelay(TimeUnit.MILLISECONDS);
                if (delay > 0) {
                    i0.d(C() + "loginWithToken: will try in " + delay + "ms (rate limit)");
                }
                com.voximplant.sdk.internal.utils.b bVar = this.f174806b;
                Runnable runnable = new Runnable() {
                    @Override
                    public final void run() {
                        l.this.L(str, map);
                    }
                };
                if (delay <= 0) {
                    delay = 1;
                }
                this.f174812h = bVar.c(runnable, delay);
                return;
            }
            this.f174805a.K(new com.voximplant.sdk.internal.proto.h0(str, "", map));
            return;
        }
        i0.c(C() + "loginWithToken: failed due to invalid state");
        this.f174808d.l(null, 491);
    }

    public void R(i1 i1Var) {
        boolean z15;
        m mVar = this.f174807c;
        m mVar2 = m.CONNECTED;
        if ((mVar == mVar2 || mVar == m.TRY_LOGIN || mVar == m.LOGGED_IN) && (i1Var instanceof p0)) {
            int b15 = ((p0) i1Var).b();
            boolean z16 = false;
            if (b15 >= 500) {
                z15 = true;
            } else {
                z15 = false;
            }
            if (b15 < 600) {
                z16 = true;
            }
            if (z15 & z16) {
                F();
            }
        }
        if (this.f174807c == m.TRY_LOGIN) {
            if (i1Var instanceof k0) {
                this.f174807c = m.LOGGED_IN;
                ScheduledFuture<?> scheduledFuture = this.f174810f;
                if (scheduledFuture != null) {
                    scheduledFuture.cancel(true);
                    this.f174810f = null;
                }
                ScheduledFuture<?> scheduledFuture2 = this.f174812h;
                if (scheduledFuture2 != null) {
                    scheduledFuture2.cancel(true);
                    this.f174812h = null;
                }
                g0 g0Var = this.f174808d;
                if (g0Var != null) {
                    g0Var.f(i1Var);
                }
            }
            if (i1Var instanceof com.voximplant.sdk.internal.proto.i0) {
                this.f174807c = mVar2;
                ScheduledFuture<?> scheduledFuture3 = this.f174810f;
                if (scheduledFuture3 != null) {
                    scheduledFuture3.cancel(true);
                    this.f174810f = null;
                }
                ScheduledFuture<?> scheduledFuture4 = this.f174812h;
                if (scheduledFuture4 != null) {
                    scheduledFuture4.cancel(true);
                    this.f174812h = null;
                }
                int b16 = ((com.voximplant.sdk.internal.proto.i0) i1Var).b();
                if (b16 >= 500 && b16 < 600) {
                    F();
                }
                g0 g0Var2 = this.f174808d;
                if (g0Var2 != null) {
                    g0Var2.l(i1Var, -1);
                }
            }
        }
    }

    public void S(final String str, final Map<String, String> map) {
        ScheduledFuture<?> scheduledFuture;
        m mVar = this.f174807c;
        if (mVar != m.CONNECTED && mVar != m.TRY_LOGIN && mVar != m.LOGGED_IN) {
            i0.j(C() + "refreshToken: failed due to invalid state");
            return;
        }
        if (this.f174818n && (scheduledFuture = this.f174811g) != null) {
            int delay = (int) scheduledFuture.getDelay(TimeUnit.MILLISECONDS);
            if (delay > 0) {
                i0.d(C() + "refreshTokens: will try in " + delay + "ms (rate limit)");
            }
            com.voximplant.sdk.internal.utils.b bVar = this.f174806b;
            Runnable runnable = new Runnable() {
                @Override
                public final void run() {
                    l.this.M(str, map);
                }
            };
            if (delay <= 0) {
                delay = 1;
            }
            this.f174812h = bVar.c(runnable, delay);
            return;
        }
        this.f174805a.K(new o0(str, map));
    }

    public void U(final String str) {
        ScheduledFuture<?> scheduledFuture;
        if (this.f174807c == m.CONNECTED) {
            this.f174807c = m.TRY_LOGIN;
            if (this.f174818n && (scheduledFuture = this.f174811g) != null) {
                int delay = (int) scheduledFuture.getDelay(TimeUnit.MILLISECONDS);
                if (delay > 0) {
                    i0.d(C() + "requestOneTimeKey: will try in " + delay + "ms (rate limit)");
                }
                com.voximplant.sdk.internal.utils.b bVar = this.f174806b;
                Runnable runnable = new Runnable() {
                    @Override
                    public final void run() {
                        l.this.N(str);
                    }
                };
                if (delay <= 0) {
                    delay = 1;
                }
                this.f174812h = bVar.c(runnable, delay);
                return;
            }
            this.f174805a.K(new com.voximplant.sdk.internal.proto.j0(str));
            return;
        }
        i0.c(C() + "requestOneTimeKey: failed due to invalid state");
        this.f174808d.l(null, 491);
    }

    public void W(g0 g0Var) {
        this.f174808d = g0Var;
    }

    @Override
    public void a() {
        this.f174807c = m.RECONNECTING;
        g0 g0Var = this.f174808d;
        if (g0Var != null) {
            g0Var.a();
        }
    }

    @Override
    public void b() {
        i0.d(C() + "onConnected");
        this.f174807c = m.CONNECTED;
        g0 g0Var = this.f174808d;
        if (g0Var != null) {
            g0Var.b();
        }
    }

    @Override
    public void c() {
        this.f174807c = m.LOGGED_IN;
        g0 g0Var = this.f174808d;
        if (g0Var != null) {
            g0Var.c();
        }
    }

    @Override
    public void d(String str) {
        i0.d(C() + "onWSClose: reason: " + str);
        ScheduledFuture<?> scheduledFuture = this.f174811g;
        if (scheduledFuture != null) {
            scheduledFuture.cancel(true);
            this.f174811g = null;
        }
        this.f174818n = false;
        ScheduledFuture<?> scheduledFuture2 = this.f174812h;
        if (scheduledFuture2 != null) {
            scheduledFuture2.cancel(true);
            this.f174812h = null;
        }
        ScheduledFuture<?> scheduledFuture3 = this.f174809e;
        if (scheduledFuture3 != null) {
            scheduledFuture3.cancel(true);
            this.f174809e = null;
        }
        this.f174815k = null;
        if (!this.f174816l) {
            m mVar = this.f174807c;
            if (mVar == m.TRY_LOGIN) {
                ScheduledFuture<?> scheduledFuture4 = this.f174810f;
                if (scheduledFuture4 != null) {
                    scheduledFuture4.cancel(true);
                    this.f174810f = null;
                }
                this.f174807c = m.DISCONNECTED;
                this.f174808d.q();
                this.f174808d.l(null, 503);
                return;
            }
            if (mVar != m.CONNECTED && mVar != m.LOGGED_IN && mVar != m.RECONNECTING) {
                m mVar2 = m.DISCONNECTED;
                if (mVar != mVar2) {
                    this.f174807c = mVar2;
                    this.f174808d.k(str);
                    return;
                }
                return;
            }
            this.f174807c = m.DISCONNECTED;
            this.f174808d.q();
            return;
        }
        this.f174807c = m.DISCONNECTED;
        this.f174816l = false;
        this.f174808d.q();
    }
}