2021-08-09 22:50:52 +00:00
|
|
|
package com.discord.utilities.websocket;
|
|
|
|
|
2021-08-18 07:29:27 +00:00
|
|
|
import c.a.q.m0.c.e;
|
2021-08-09 22:50:52 +00:00
|
|
|
import com.discord.models.domain.ModelAuditLogEntry;
|
|
|
|
import com.discord.utilities.websocket.WebSocket;
|
|
|
|
import com.discord.utilities.websocket.ZLibWebSocketListener;
|
|
|
|
import d0.o;
|
|
|
|
import d0.t.g0;
|
|
|
|
import d0.t.h0;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.util.Map;
|
|
|
|
import okhttp3.Response;
|
|
|
|
import okhttp3.WebSocket;
|
|
|
|
/* compiled from: WebSocket.kt */
|
|
|
|
public final class WebSocket$connect$1 extends ZLibWebSocketListener.Listener {
|
|
|
|
private final RawMessageHandler rawMessageHandler;
|
|
|
|
public final /* synthetic */ WebSocket this$0;
|
|
|
|
|
|
|
|
public WebSocket$connect$1(WebSocket webSocket) {
|
|
|
|
this.this$0 = webSocket;
|
|
|
|
this.rawMessageHandler = webSocket.getRawMessageHandler();
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void handleError(Exception exc, String str, String str2) {
|
|
|
|
Map map;
|
|
|
|
if (str2 == null || (map = g0.mapOf(o.to("raw_data_string", str2))) == null) {
|
|
|
|
map = h0.emptyMap();
|
|
|
|
}
|
|
|
|
WebSocket.access$getErrorLogger$p(this.this$0).invoke(str, exc, map);
|
|
|
|
WebSocket.access$handleOnFailure(this.this$0, exc, null, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static /* synthetic */ void handleError$default(WebSocket$connect$1 webSocket$connect$1, Exception exc, String str, String str2, int i, Object obj) {
|
|
|
|
if ((i & 4) != 0) {
|
|
|
|
str2 = null;
|
|
|
|
}
|
|
|
|
webSocket$connect$1.handleError(exc, str, str2);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.utilities.websocket.ZLibWebSocketListener.Listener
|
|
|
|
public RawMessageHandler getRawMessageHandler() {
|
|
|
|
return this.rawMessageHandler;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okhttp3.WebSocketListener
|
|
|
|
public void onClosed(WebSocket webSocket, int i, String str) {
|
|
|
|
m.checkNotNullParameter(webSocket, "webSocket");
|
|
|
|
m.checkNotNullParameter(str, ModelAuditLogEntry.CHANGE_KEY_REASON);
|
|
|
|
WebSocket.access$schedule(this.this$0, new WebSocket$connect$1$onClosed$1(this, i, str));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okhttp3.WebSocketListener
|
|
|
|
public void onClosing(WebSocket webSocket, int i, String str) {
|
|
|
|
m.checkNotNullParameter(webSocket, "webSocket");
|
|
|
|
m.checkNotNullParameter(str, ModelAuditLogEntry.CHANGE_KEY_REASON);
|
|
|
|
WebSocket.access$setState$p(this.this$0, WebSocket.State.CLOSING);
|
|
|
|
this.this$0.getOnClosed().invoke(new WebSocket.Closed(i, str));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okhttp3.WebSocketListener
|
|
|
|
public void onFailure(okhttp3.WebSocket webSocket, Throwable th, Response response) {
|
|
|
|
m.checkNotNullParameter(webSocket, "webSocket");
|
|
|
|
m.checkNotNullParameter(th, "t");
|
|
|
|
WebSocket.access$schedule(this.this$0, new WebSocket$connect$1$onFailure$1(this, th, response));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.utilities.websocket.ZLibWebSocketListener.Listener
|
|
|
|
public void onInflateError(Exception exc) {
|
|
|
|
m.checkNotNullParameter(exc, e.a);
|
|
|
|
handleError$default(this, exc, "Unable to inflate message.", null, 4, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.utilities.websocket.ZLibWebSocketListener.Listener
|
|
|
|
public void onInflatedMessage(okhttp3.WebSocket webSocket, InputStreamReader inputStreamReader, int i) {
|
|
|
|
m.checkNotNullParameter(webSocket, "webSocket");
|
|
|
|
m.checkNotNullParameter(inputStreamReader, "reader");
|
|
|
|
try {
|
|
|
|
this.this$0.getOnMessage().invoke(inputStreamReader, Integer.valueOf(i));
|
|
|
|
} catch (Exception e) {
|
|
|
|
handleError$default(this, e, "Unable to parse model.", null, 4, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // okhttp3.WebSocketListener
|
|
|
|
public void onOpen(okhttp3.WebSocket webSocket, Response response) {
|
|
|
|
m.checkNotNullParameter(webSocket, "webSocket");
|
|
|
|
m.checkNotNullParameter(response, "response");
|
|
|
|
WebSocket.access$schedule(this.this$0, new WebSocket$connect$1$onOpen$1(this, webSocket, response));
|
|
|
|
}
|
|
|
|
}
|