447 lines
12 KiB
Smali
447 lines
12 KiB
Smali
.class public final Lcom/discord/utilities/websocket/ZLibWebSocketListener;
|
|
.super Lokhttp3/WebSocketListener;
|
|
.source "ZLibWebSocketListener.kt"
|
|
|
|
|
|
# annotations
|
|
.annotation system Ldalvik/annotation/MemberClasses;
|
|
value = {
|
|
Lcom/discord/utilities/websocket/ZLibWebSocketListener$ZLibByteStream;,
|
|
Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;
|
|
}
|
|
.end annotation
|
|
|
|
|
|
# instance fields
|
|
.field public final inflater:Ljava/util/zip/Inflater;
|
|
|
|
.field public final listener:Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;
|
|
|
|
.field public final loggingInflater:Ljava/util/zip/Inflater;
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>(Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;)V
|
|
.locals 0
|
|
|
|
if-eqz p1, :cond_0
|
|
|
|
invoke-direct {p0}, Lokhttp3/WebSocketListener;-><init>()V
|
|
|
|
iput-object p1, p0, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->listener:Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;
|
|
|
|
new-instance p1, Ljava/util/zip/Inflater;
|
|
|
|
invoke-direct {p1}, Ljava/util/zip/Inflater;-><init>()V
|
|
|
|
iput-object p1, p0, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->loggingInflater:Ljava/util/zip/Inflater;
|
|
|
|
new-instance p1, Ljava/util/zip/Inflater;
|
|
|
|
invoke-direct {p1}, Ljava/util/zip/Inflater;-><init>()V
|
|
|
|
iput-object p1, p0, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->inflater:Ljava/util/zip/Inflater;
|
|
|
|
return-void
|
|
|
|
:cond_0
|
|
const-string p1, "listener"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
const/4 p1, 0x0
|
|
|
|
throw p1
|
|
.end method
|
|
|
|
.method private final resetInflaters()V
|
|
.locals 1
|
|
|
|
iget-object v0, p0, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->inflater:Ljava/util/zip/Inflater;
|
|
|
|
invoke-virtual {v0}, Ljava/util/zip/Inflater;->reset()V
|
|
|
|
iget-object v0, p0, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->loggingInflater:Ljava/util/zip/Inflater;
|
|
|
|
invoke-virtual {v0}, Ljava/util/zip/Inflater;->reset()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public final getListener()Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;
|
|
.locals 1
|
|
|
|
iget-object v0, p0, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->listener:Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public onClosed(Lokhttp3/WebSocket;ILjava/lang/String;)V
|
|
.locals 1
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-eqz p1, :cond_1
|
|
|
|
if-eqz p3, :cond_0
|
|
|
|
invoke-direct {p0}, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->resetInflaters()V
|
|
|
|
iget-object v0, p0, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->listener:Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;
|
|
|
|
invoke-virtual {v0, p1, p2, p3}, Lokhttp3/WebSocketListener;->onClosed(Lokhttp3/WebSocket;ILjava/lang/String;)V
|
|
|
|
return-void
|
|
|
|
:cond_0
|
|
const-string p1, "reason"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
|
|
:cond_1
|
|
const-string p1, "webSocket"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
.end method
|
|
|
|
.method public onClosing(Lokhttp3/WebSocket;ILjava/lang/String;)V
|
|
.locals 1
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-eqz p1, :cond_1
|
|
|
|
if-eqz p3, :cond_0
|
|
|
|
invoke-direct {p0}, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->resetInflaters()V
|
|
|
|
iget-object v0, p0, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->listener:Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;
|
|
|
|
invoke-virtual {v0, p1, p2, p3}, Lokhttp3/WebSocketListener;->onClosing(Lokhttp3/WebSocket;ILjava/lang/String;)V
|
|
|
|
return-void
|
|
|
|
:cond_0
|
|
const-string p1, "reason"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
|
|
:cond_1
|
|
const-string p1, "webSocket"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
.end method
|
|
|
|
.method public onFailure(Lokhttp3/WebSocket;Ljava/lang/Throwable;Lokhttp3/Response;)V
|
|
.locals 1
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-eqz p1, :cond_1
|
|
|
|
if-eqz p2, :cond_0
|
|
|
|
invoke-direct {p0}, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->resetInflaters()V
|
|
|
|
iget-object v0, p0, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->listener:Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;
|
|
|
|
invoke-virtual {v0, p1, p2, p3}, Lokhttp3/WebSocketListener;->onFailure(Lokhttp3/WebSocket;Ljava/lang/Throwable;Lokhttp3/Response;)V
|
|
|
|
return-void
|
|
|
|
:cond_0
|
|
const-string p1, "t"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
|
|
:cond_1
|
|
const-string p1, "webSocket"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
.end method
|
|
|
|
.method public onMessage(Lokhttp3/WebSocket;Ljava/lang/String;)V
|
|
.locals 1
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-eqz p1, :cond_1
|
|
|
|
if-eqz p2, :cond_0
|
|
|
|
iget-object v0, p0, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->listener:Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;
|
|
|
|
invoke-virtual {v0, p1, p2}, Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;->onMessage(Lokhttp3/WebSocket;Ljava/lang/String;)V
|
|
|
|
return-void
|
|
|
|
:cond_0
|
|
const-string p1, "text"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
|
|
:cond_1
|
|
const-string p1, "webSocket"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
.end method
|
|
|
|
.method public onMessage(Lokhttp3/WebSocket;Lokio/ByteString;)V
|
|
.locals 6
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-eqz p1, :cond_6
|
|
|
|
if-eqz p2, :cond_5
|
|
|
|
iget-object v1, p0, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->listener:Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;
|
|
|
|
invoke-virtual {v1}, Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;->getRawMessageHandler()Lcom/discord/utilities/websocket/RawMessageHandler;
|
|
|
|
move-result-object v1
|
|
|
|
if-eqz v1, :cond_4
|
|
|
|
:try_start_0
|
|
new-instance v1, Lcom/discord/utilities/websocket/ZLibWebSocketListener$ZLibByteStream;
|
|
|
|
iget-object v2, p0, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->loggingInflater:Ljava/util/zip/Inflater;
|
|
|
|
invoke-direct {v1, p2, v2}, Lcom/discord/utilities/websocket/ZLibWebSocketListener$ZLibByteStream;-><init>(Lokio/ByteString;Ljava/util/zip/Inflater;)V
|
|
|
|
invoke-virtual {v1}, Lcom/discord/utilities/websocket/ZLibWebSocketListener$ZLibByteStream;->toReader()Ljava/io/InputStreamReader;
|
|
|
|
move-result-object v1
|
|
:try_end_0
|
|
.catchall {:try_start_0 .. :try_end_0} :catchall_2
|
|
|
|
if-eqz v1, :cond_2
|
|
|
|
:try_start_1
|
|
new-instance v2, Ljava/io/StringWriter;
|
|
|
|
invoke-direct {v2}, Ljava/io/StringWriter;-><init>()V
|
|
|
|
const/16 v3, 0x2000
|
|
|
|
new-array v3, v3, [C
|
|
|
|
invoke-virtual {v1, v3}, Ljava/io/Reader;->read([C)I
|
|
|
|
move-result v4
|
|
|
|
:goto_0
|
|
if-ltz v4, :cond_0
|
|
|
|
const/4 v5, 0x0
|
|
|
|
invoke-virtual {v2, v3, v5, v4}, Ljava/io/Writer;->write([CII)V
|
|
|
|
invoke-virtual {v1, v3}, Ljava/io/Reader;->read([C)I
|
|
|
|
move-result v4
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
invoke-virtual {v2}, Ljava/io/StringWriter;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v2
|
|
|
|
const-string v3, "buffer.toString()"
|
|
|
|
invoke-static {v2, v3}, Ly/u/b/j;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
iget-object v3, p0, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->listener:Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;
|
|
|
|
invoke-virtual {v3}, Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;->getRawMessageHandler()Lcom/discord/utilities/websocket/RawMessageHandler;
|
|
|
|
move-result-object v3
|
|
|
|
if-eqz v3, :cond_1
|
|
|
|
invoke-interface {v3, v2}, Lcom/discord/utilities/websocket/RawMessageHandler;->onRawMessage(Ljava/lang/String;)V
|
|
:try_end_1
|
|
.catchall {:try_start_1 .. :try_end_1} :catchall_0
|
|
|
|
:try_start_2
|
|
invoke-static {v1, v0}, Le/k/a/c/e/p/g;->closeFinally(Ljava/io/Closeable;Ljava/lang/Throwable;)V
|
|
:try_end_2
|
|
.catchall {:try_start_2 .. :try_end_2} :catchall_2
|
|
|
|
goto :goto_2
|
|
|
|
:cond_1
|
|
:try_start_3
|
|
invoke-static {}, Ly/u/b/j;->throwNpe()V
|
|
:try_end_3
|
|
.catchall {:try_start_3 .. :try_end_3} :catchall_0
|
|
|
|
throw v0
|
|
|
|
:catchall_0
|
|
move-exception v2
|
|
|
|
goto :goto_1
|
|
|
|
:cond_2
|
|
:try_start_4
|
|
const-string v2, "$this$readText"
|
|
|
|
invoke-static {v2}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
:try_end_4
|
|
.catchall {:try_start_4 .. :try_end_4} :catchall_0
|
|
|
|
throw v0
|
|
|
|
:goto_1
|
|
:try_start_5
|
|
throw v2
|
|
:try_end_5
|
|
.catchall {:try_start_5 .. :try_end_5} :catchall_1
|
|
|
|
:catchall_1
|
|
move-exception v3
|
|
|
|
:try_start_6
|
|
invoke-static {v1, v2}, Le/k/a/c/e/p/g;->closeFinally(Ljava/io/Closeable;Ljava/lang/Throwable;)V
|
|
|
|
throw v3
|
|
:try_end_6
|
|
.catchall {:try_start_6 .. :try_end_6} :catchall_2
|
|
|
|
:catchall_2
|
|
move-exception v1
|
|
|
|
iget-object v2, p0, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->listener:Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;
|
|
|
|
invoke-virtual {v2}, Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;->getRawMessageHandler()Lcom/discord/utilities/websocket/RawMessageHandler;
|
|
|
|
move-result-object v2
|
|
|
|
if-eqz v2, :cond_3
|
|
|
|
invoke-interface {v2, v1}, Lcom/discord/utilities/websocket/RawMessageHandler;->onRawMessageInflateFailed(Ljava/lang/Throwable;)V
|
|
|
|
goto :goto_2
|
|
|
|
:cond_3
|
|
invoke-static {}, Ly/u/b/j;->throwNpe()V
|
|
|
|
throw v0
|
|
|
|
:cond_4
|
|
:goto_2
|
|
:try_start_7
|
|
new-instance v1, Lcom/discord/utilities/websocket/ZLibWebSocketListener$ZLibByteStream;
|
|
|
|
iget-object v2, p0, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->inflater:Ljava/util/zip/Inflater;
|
|
|
|
invoke-direct {v1, p2, v2}, Lcom/discord/utilities/websocket/ZLibWebSocketListener$ZLibByteStream;-><init>(Lokio/ByteString;Ljava/util/zip/Inflater;)V
|
|
|
|
invoke-virtual {v1}, Lcom/discord/utilities/websocket/ZLibWebSocketListener$ZLibByteStream;->toReader()Ljava/io/InputStreamReader;
|
|
|
|
move-result-object p2
|
|
:try_end_7
|
|
.catch Ljava/lang/Exception; {:try_start_7 .. :try_end_7} :catch_0
|
|
|
|
:try_start_8
|
|
iget-object v1, p0, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->listener:Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;
|
|
|
|
invoke-virtual {v1, p1, p2}, Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;->onInflatedMessage(Lokhttp3/WebSocket;Ljava/io/InputStreamReader;)V
|
|
:try_end_8
|
|
.catchall {:try_start_8 .. :try_end_8} :catchall_3
|
|
|
|
invoke-static {p2, v0}, Le/k/a/c/e/p/g;->closeFinally(Ljava/io/Closeable;Ljava/lang/Throwable;)V
|
|
|
|
return-void
|
|
|
|
:catchall_3
|
|
move-exception p1
|
|
|
|
:try_start_9
|
|
throw p1
|
|
:try_end_9
|
|
.catchall {:try_start_9 .. :try_end_9} :catchall_4
|
|
|
|
:catchall_4
|
|
move-exception v0
|
|
|
|
invoke-static {p2, p1}, Le/k/a/c/e/p/g;->closeFinally(Ljava/io/Closeable;Ljava/lang/Throwable;)V
|
|
|
|
throw v0
|
|
|
|
:catch_0
|
|
move-exception p1
|
|
|
|
iget-object p2, p0, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->listener:Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;
|
|
|
|
invoke-virtual {p2, p1}, Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;->onInflateError(Ljava/lang/Exception;)V
|
|
|
|
return-void
|
|
|
|
:cond_5
|
|
const-string p1, "bytes"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
|
|
:cond_6
|
|
const-string p1, "webSocket"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
.end method
|
|
|
|
.method public onOpen(Lokhttp3/WebSocket;Lokhttp3/Response;)V
|
|
.locals 1
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-eqz p1, :cond_1
|
|
|
|
if-eqz p2, :cond_0
|
|
|
|
invoke-direct {p0}, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->resetInflaters()V
|
|
|
|
iget-object v0, p0, Lcom/discord/utilities/websocket/ZLibWebSocketListener;->listener:Lcom/discord/utilities/websocket/ZLibWebSocketListener$Listener;
|
|
|
|
invoke-virtual {v0, p1, p2}, Lokhttp3/WebSocketListener;->onOpen(Lokhttp3/WebSocket;Lokhttp3/Response;)V
|
|
|
|
return-void
|
|
|
|
:cond_0
|
|
const-string p1, "response"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
|
|
:cond_1
|
|
const-string p1, "webSocket"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
.end method
|