12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715 |
- .class public final Lokhttp3/internal/ws/RealWebSocket;
- .super Ljava/lang/Object;
- .source ""
- # interfaces
- .implements Lokhttp3/WebSocket;
- .implements Lokhttp3/internal/ws/WebSocketReader$FrameCallback;
- # annotations
- .annotation system Ldalvik/annotation/MemberClasses;
- value = {
- Lokhttp3/internal/ws/RealWebSocket$CancelRunnable;,
- Lokhttp3/internal/ws/RealWebSocket$Streams;,
- Lokhttp3/internal/ws/RealWebSocket$Close;,
- Lokhttp3/internal/ws/RealWebSocket$Message;,
- Lokhttp3/internal/ws/RealWebSocket$PingRunnable;
- }
- .end annotation
- # static fields
- .field static final synthetic $assertionsDisabled:Z = false
- .field private static final CANCEL_AFTER_CLOSE_MILLIS:J = 0xea60L
- .field private static final MAX_QUEUE_SIZE:J = 0x1000000L
- .field private static final ONLY_HTTP1:Ljava/util/List;
- .annotation system Ldalvik/annotation/Signature;
- value = {
- "Ljava/util/List<",
- "Lokhttp3/Protocol;",
- ">;"
- }
- .end annotation
- .end field
- # instance fields
- .field private call:Lokhttp3/Call;
- .field private cancelFuture:Ljava/util/concurrent/ScheduledFuture;
- .annotation system Ldalvik/annotation/Signature;
- value = {
- "Ljava/util/concurrent/ScheduledFuture<",
- "*>;"
- }
- .end annotation
- .end field
- .field private enqueuedClose:Z
- .field private executor:Ljava/util/concurrent/ScheduledExecutorService;
- .field private failed:Z
- .field private final key:Ljava/lang/String;
- .field final listener:Lokhttp3/WebSocketListener;
- .field private final messageAndCloseQueue:Ljava/util/ArrayDeque;
- .annotation system Ldalvik/annotation/Signature;
- value = {
- "Ljava/util/ArrayDeque<",
- "Ljava/lang/Object;",
- ">;"
- }
- .end annotation
- .end field
- .field private final originalRequest:Lokhttp3/Request;
- .field pingCount:I
- .field pongCount:I
- .field private final pongQueue:Ljava/util/ArrayDeque;
- .annotation system Ldalvik/annotation/Signature;
- value = {
- "Ljava/util/ArrayDeque<",
- "Lokio/ByteString;",
- ">;"
- }
- .end annotation
- .end field
- .field private queueSize:J
- .field private final random:Ljava/util/Random;
- .field private reader:Lokhttp3/internal/ws/WebSocketReader;
- .field private receivedCloseCode:I
- .field private receivedCloseReason:Ljava/lang/String;
- .field private streams:Lokhttp3/internal/ws/RealWebSocket$Streams;
- .field private writer:Lokhttp3/internal/ws/WebSocketWriter;
- .field private final writerRunnable:Ljava/lang/Runnable;
- # direct methods
- .method static constructor <clinit>()V
- .locals 1
- sget-object v0, Lokhttp3/Protocol;->HTTP_1_1:Lokhttp3/Protocol;
- invoke-static {v0}, Ljava/util/Collections;->singletonList(Ljava/lang/Object;)Ljava/util/List;
- move-result-object v0
- sput-object v0, Lokhttp3/internal/ws/RealWebSocket;->ONLY_HTTP1:Ljava/util/List;
- return-void
- .end method
- .method public constructor <init>(Lokhttp3/Request;Lokhttp3/WebSocketListener;Ljava/util/Random;)V
- .locals 2
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- new-instance v0, Ljava/util/ArrayDeque;
- invoke-direct {v0}, Ljava/util/ArrayDeque;-><init>()V
- iput-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->pongQueue:Ljava/util/ArrayDeque;
- new-instance v0, Ljava/util/ArrayDeque;
- invoke-direct {v0}, Ljava/util/ArrayDeque;-><init>()V
- iput-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->messageAndCloseQueue:Ljava/util/ArrayDeque;
- const/4 v0, -0x1
- iput v0, p0, Lokhttp3/internal/ws/RealWebSocket;->receivedCloseCode:I
- invoke-virtual {p1}, Lokhttp3/Request;->method()Ljava/lang/String;
- move-result-object v0
- const-string v1, "GET"
- invoke-virtual {v1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
- move-result v0
- if-eqz v0, :cond_0
- iput-object p1, p0, Lokhttp3/internal/ws/RealWebSocket;->originalRequest:Lokhttp3/Request;
- iput-object p2, p0, Lokhttp3/internal/ws/RealWebSocket;->listener:Lokhttp3/WebSocketListener;
- iput-object p3, p0, Lokhttp3/internal/ws/RealWebSocket;->random:Ljava/util/Random;
- const/16 p1, 0x10
- new-array p1, p1, [B
- invoke-virtual {p3, p1}, Ljava/util/Random;->nextBytes([B)V
- invoke-static {p1}, Lokio/ByteString;->of([B)Lokio/ByteString;
- move-result-object p1
- invoke-virtual {p1}, Lokio/ByteString;->base64()Ljava/lang/String;
- move-result-object p1
- iput-object p1, p0, Lokhttp3/internal/ws/RealWebSocket;->key:Ljava/lang/String;
- new-instance p1, Lokhttp3/internal/ws/RealWebSocket$1;
- invoke-direct {p1, p0}, Lokhttp3/internal/ws/RealWebSocket$1;-><init>(Lokhttp3/internal/ws/RealWebSocket;)V
- iput-object p1, p0, Lokhttp3/internal/ws/RealWebSocket;->writerRunnable:Ljava/lang/Runnable;
- return-void
- :cond_0
- new-instance p2, Ljava/lang/IllegalArgumentException;
- new-instance p3, Ljava/lang/StringBuilder;
- invoke-direct {p3}, Ljava/lang/StringBuilder;-><init>()V
- const-string v0, "Request must be GET: "
- invoke-virtual {p3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {p1}, Lokhttp3/Request;->method()Ljava/lang/String;
- move-result-object p1
- invoke-virtual {p3, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {p3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object p1
- invoke-direct {p2, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
- throw p2
- .end method
- .method private runWriter()V
- .locals 2
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->executor:Ljava/util/concurrent/ScheduledExecutorService;
- if-eqz v0, :cond_0
- iget-object v1, p0, Lokhttp3/internal/ws/RealWebSocket;->writerRunnable:Ljava/lang/Runnable;
- invoke-interface {v0, v1}, Ljava/util/concurrent/ScheduledExecutorService;->execute(Ljava/lang/Runnable;)V
- :cond_0
- return-void
- .end method
- .method private declared-synchronized send(Lokio/ByteString;I)Z
- .locals 6
- monitor-enter p0
- :try_start_0
- iget-boolean v0, p0, Lokhttp3/internal/ws/RealWebSocket;->failed:Z
- const/4 v1, 0x0
- if-nez v0, :cond_2
- iget-boolean v0, p0, Lokhttp3/internal/ws/RealWebSocket;->enqueuedClose:Z
- if-eqz v0, :cond_0
- goto :goto_0
- :cond_0
- iget-wide v2, p0, Lokhttp3/internal/ws/RealWebSocket;->queueSize:J
- invoke-virtual {p1}, Lokio/ByteString;->size()I
- move-result v0
- int-to-long v4, v0
- add-long/2addr v2, v4
- const-wide/32 v4, 0x1000000
- cmp-long v0, v2, v4
- if-lez v0, :cond_1
- const/16 p1, 0x3e9
- const/4 p2, 0x0
- invoke-virtual {p0, p1, p2}, Lokhttp3/internal/ws/RealWebSocket;->close(ILjava/lang/String;)Z
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_0
- monitor-exit p0
- return v1
- :cond_1
- :try_start_1
- iget-wide v0, p0, Lokhttp3/internal/ws/RealWebSocket;->queueSize:J
- invoke-virtual {p1}, Lokio/ByteString;->size()I
- move-result v2
- int-to-long v2, v2
- add-long/2addr v0, v2
- iput-wide v0, p0, Lokhttp3/internal/ws/RealWebSocket;->queueSize:J
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->messageAndCloseQueue:Ljava/util/ArrayDeque;
- new-instance v1, Lokhttp3/internal/ws/RealWebSocket$Message;
- invoke-direct {v1, p2, p1}, Lokhttp3/internal/ws/RealWebSocket$Message;-><init>(ILokio/ByteString;)V
- invoke-virtual {v0, v1}, Ljava/util/ArrayDeque;->add(Ljava/lang/Object;)Z
- invoke-direct {p0}, Lokhttp3/internal/ws/RealWebSocket;->runWriter()V
- :try_end_1
- .catchall {:try_start_1 .. :try_end_1} :catchall_0
- const/4 p1, 0x1
- monitor-exit p0
- return p1
- :cond_2
- :goto_0
- monitor-exit p0
- return v1
- :catchall_0
- move-exception p1
- monitor-exit p0
- throw p1
- .end method
- # virtual methods
- .method awaitTermination(ILjava/util/concurrent/TimeUnit;)V
- .locals 3
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/lang/InterruptedException;
- }
- .end annotation
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->executor:Ljava/util/concurrent/ScheduledExecutorService;
- int-to-long v1, p1
- invoke-interface {v0, v1, v2, p2}, Ljava/util/concurrent/ScheduledExecutorService;->awaitTermination(JLjava/util/concurrent/TimeUnit;)Z
- return-void
- .end method
- .method public cancel()V
- .locals 1
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->call:Lokhttp3/Call;
- invoke-interface {v0}, Lokhttp3/Call;->cancel()V
- return-void
- .end method
- .method checkResponse(Lokhttp3/Response;)V
- .locals 5
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/net/ProtocolException;
- }
- .end annotation
- invoke-virtual {p1}, Lokhttp3/Response;->code()I
- move-result v0
- const-string v1, "\'"
- const/16 v2, 0x65
- if-ne v0, v2, :cond_3
- const-string v0, "Connection"
- invoke-virtual {p1, v0}, Lokhttp3/Response;->header(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- const-string v2, "Upgrade"
- invoke-virtual {v2, v0}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
- move-result v3
- if-eqz v3, :cond_2
- invoke-virtual {p1, v2}, Lokhttp3/Response;->header(Ljava/lang/String;)Ljava/lang/String;
- move-result-object v0
- const-string v2, "websocket"
- invoke-virtual {v2, v0}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
- move-result v2
- if-eqz v2, :cond_1
- const-string v0, "Sec-WebSocket-Accept"
- invoke-virtual {p1, v0}, Lokhttp3/Response;->header(Ljava/lang/String;)Ljava/lang/String;
- move-result-object p1
- new-instance v0, Ljava/lang/StringBuilder;
- invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
- iget-object v2, p0, Lokhttp3/internal/ws/RealWebSocket;->key:Ljava/lang/String;
- invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- const-string v2, "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"
- invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object v0
- invoke-static {v0}, Lokio/ByteString;->encodeUtf8(Ljava/lang/String;)Lokio/ByteString;
- move-result-object v0
- invoke-virtual {v0}, Lokio/ByteString;->sha1()Lokio/ByteString;
- move-result-object v0
- invoke-virtual {v0}, Lokio/ByteString;->base64()Ljava/lang/String;
- move-result-object v0
- invoke-virtual {v0, p1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
- move-result v2
- if-eqz v2, :cond_0
- return-void
- :cond_0
- new-instance v2, Ljava/net/ProtocolException;
- new-instance v3, Ljava/lang/StringBuilder;
- invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
- const-string v4, "Expected \'Sec-WebSocket-Accept\' header value \'"
- invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- const-string v0, "\' but was \'"
- invoke-virtual {v3, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v3, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v3, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object p1
- invoke-direct {v2, p1}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
- throw v2
- :cond_1
- new-instance p1, Ljava/net/ProtocolException;
- new-instance v2, Ljava/lang/StringBuilder;
- invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
- const-string v3, "Expected \'Upgrade\' header value \'websocket\' but was \'"
- invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object v0
- invoke-direct {p1, v0}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
- throw p1
- :cond_2
- new-instance p1, Ljava/net/ProtocolException;
- new-instance v2, Ljava/lang/StringBuilder;
- invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
- const-string v3, "Expected \'Connection\' header value \'Upgrade\' but was \'"
- invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object v0
- invoke-direct {p1, v0}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
- throw p1
- :cond_3
- new-instance v0, Ljava/net/ProtocolException;
- new-instance v2, Ljava/lang/StringBuilder;
- invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
- const-string v3, "Expected HTTP 101 response but was \'"
- invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {p1}, Lokhttp3/Response;->code()I
- move-result v3
- invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
- const-string v3, " "
- invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {p1}, Lokhttp3/Response;->message()Ljava/lang/String;
- move-result-object p1
- invoke-virtual {v2, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object p1
- invoke-direct {v0, p1}, Ljava/net/ProtocolException;-><init>(Ljava/lang/String;)V
- throw v0
- .end method
- .method public close(ILjava/lang/String;)Z
- .locals 2
- const-wide/32 v0, 0xea60
- invoke-virtual {p0, p1, p2, v0, v1}, Lokhttp3/internal/ws/RealWebSocket;->close(ILjava/lang/String;J)Z
- move-result p1
- return p1
- .end method
- .method declared-synchronized close(ILjava/lang/String;J)Z
- .locals 6
- monitor-enter p0
- :try_start_0
- invoke-static {p1}, Lokhttp3/internal/ws/WebSocketProtocol;->validateCloseCode(I)V
- const/4 v0, 0x0
- if-eqz p2, :cond_1
- invoke-static {p2}, Lokio/ByteString;->encodeUtf8(Ljava/lang/String;)Lokio/ByteString;
- move-result-object v0
- invoke-virtual {v0}, Lokio/ByteString;->size()I
- move-result v1
- int-to-long v1, v1
- const-wide/16 v3, 0x7b
- cmp-long v5, v1, v3
- if-gtz v5, :cond_0
- goto :goto_0
- :cond_0
- new-instance p1, Ljava/lang/IllegalArgumentException;
- new-instance p3, Ljava/lang/StringBuilder;
- invoke-direct {p3}, Ljava/lang/StringBuilder;-><init>()V
- const-string p4, "reason.size() > 123: "
- invoke-virtual {p3, p4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {p3, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
- invoke-virtual {p3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
- move-result-object p2
- invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
- throw p1
- :cond_1
- :goto_0
- iget-boolean p2, p0, Lokhttp3/internal/ws/RealWebSocket;->failed:Z
- if-nez p2, :cond_3
- iget-boolean p2, p0, Lokhttp3/internal/ws/RealWebSocket;->enqueuedClose:Z
- if-eqz p2, :cond_2
- goto :goto_1
- :cond_2
- const/4 p2, 0x1
- iput-boolean p2, p0, Lokhttp3/internal/ws/RealWebSocket;->enqueuedClose:Z
- iget-object v1, p0, Lokhttp3/internal/ws/RealWebSocket;->messageAndCloseQueue:Ljava/util/ArrayDeque;
- new-instance v2, Lokhttp3/internal/ws/RealWebSocket$Close;
- invoke-direct {v2, p1, v0, p3, p4}, Lokhttp3/internal/ws/RealWebSocket$Close;-><init>(ILokio/ByteString;J)V
- invoke-virtual {v1, v2}, Ljava/util/ArrayDeque;->add(Ljava/lang/Object;)Z
- invoke-direct {p0}, Lokhttp3/internal/ws/RealWebSocket;->runWriter()V
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_0
- monitor-exit p0
- return p2
- :cond_3
- :goto_1
- const/4 p1, 0x0
- monitor-exit p0
- return p1
- :catchall_0
- move-exception p1
- monitor-exit p0
- throw p1
- .end method
- .method public connect(Lokhttp3/OkHttpClient;)V
- .locals 4
- invoke-virtual {p1}, Lokhttp3/OkHttpClient;->newBuilder()Lokhttp3/OkHttpClient$Builder;
- move-result-object p1
- sget-object v0, Lokhttp3/EventListener;->NONE:Lokhttp3/EventListener;
- invoke-virtual {p1, v0}, Lokhttp3/OkHttpClient$Builder;->eventListener(Lokhttp3/EventListener;)Lokhttp3/OkHttpClient$Builder;
- move-result-object p1
- sget-object v0, Lokhttp3/internal/ws/RealWebSocket;->ONLY_HTTP1:Ljava/util/List;
- invoke-virtual {p1, v0}, Lokhttp3/OkHttpClient$Builder;->protocols(Ljava/util/List;)Lokhttp3/OkHttpClient$Builder;
- move-result-object p1
- invoke-virtual {p1}, Lokhttp3/OkHttpClient$Builder;->build()Lokhttp3/OkHttpClient;
- move-result-object p1
- invoke-virtual {p1}, Lokhttp3/OkHttpClient;->pingIntervalMillis()I
- move-result v0
- iget-object v1, p0, Lokhttp3/internal/ws/RealWebSocket;->originalRequest:Lokhttp3/Request;
- invoke-virtual {v1}, Lokhttp3/Request;->newBuilder()Lokhttp3/Request$Builder;
- move-result-object v1
- const-string v2, "Upgrade"
- const-string v3, "websocket"
- invoke-virtual {v1, v2, v3}, Lokhttp3/Request$Builder;->header(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Request$Builder;
- move-result-object v1
- const-string v3, "Connection"
- invoke-virtual {v1, v3, v2}, Lokhttp3/Request$Builder;->header(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Request$Builder;
- move-result-object v1
- iget-object v2, p0, Lokhttp3/internal/ws/RealWebSocket;->key:Ljava/lang/String;
- const-string v3, "Sec-WebSocket-Key"
- invoke-virtual {v1, v3, v2}, Lokhttp3/Request$Builder;->header(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Request$Builder;
- move-result-object v1
- const-string v2, "Sec-WebSocket-Version"
- const-string v3, "13"
- invoke-virtual {v1, v2, v3}, Lokhttp3/Request$Builder;->header(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Request$Builder;
- move-result-object v1
- invoke-virtual {v1}, Lokhttp3/Request$Builder;->build()Lokhttp3/Request;
- move-result-object v1
- sget-object v2, Lokhttp3/internal/Internal;->instance:Lokhttp3/internal/Internal;
- invoke-virtual {v2, p1, v1}, Lokhttp3/internal/Internal;->newWebSocketCall(Lokhttp3/OkHttpClient;Lokhttp3/Request;)Lokhttp3/Call;
- move-result-object p1
- iput-object p1, p0, Lokhttp3/internal/ws/RealWebSocket;->call:Lokhttp3/Call;
- iget-object p1, p0, Lokhttp3/internal/ws/RealWebSocket;->call:Lokhttp3/Call;
- new-instance v2, Lokhttp3/internal/ws/RealWebSocket$2;
- invoke-direct {v2, p0, v1, v0}, Lokhttp3/internal/ws/RealWebSocket$2;-><init>(Lokhttp3/internal/ws/RealWebSocket;Lokhttp3/Request;I)V
- invoke-interface {p1, v2}, Lokhttp3/Call;->enqueue(Lokhttp3/Callback;)V
- return-void
- .end method
- .method public failWebSocket(Ljava/lang/Exception;Lokhttp3/Response;)V
- .locals 3
- monitor-enter p0
- :try_start_0
- iget-boolean v0, p0, Lokhttp3/internal/ws/RealWebSocket;->failed:Z
- if-eqz v0, :cond_0
- monitor-exit p0
- return-void
- :cond_0
- const/4 v0, 0x1
- iput-boolean v0, p0, Lokhttp3/internal/ws/RealWebSocket;->failed:Z
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->streams:Lokhttp3/internal/ws/RealWebSocket$Streams;
- const/4 v1, 0x0
- iput-object v1, p0, Lokhttp3/internal/ws/RealWebSocket;->streams:Lokhttp3/internal/ws/RealWebSocket$Streams;
- iget-object v1, p0, Lokhttp3/internal/ws/RealWebSocket;->cancelFuture:Ljava/util/concurrent/ScheduledFuture;
- if-eqz v1, :cond_1
- iget-object v1, p0, Lokhttp3/internal/ws/RealWebSocket;->cancelFuture:Ljava/util/concurrent/ScheduledFuture;
- const/4 v2, 0x0
- invoke-interface {v1, v2}, Ljava/util/concurrent/ScheduledFuture;->cancel(Z)Z
- :cond_1
- iget-object v1, p0, Lokhttp3/internal/ws/RealWebSocket;->executor:Ljava/util/concurrent/ScheduledExecutorService;
- if-eqz v1, :cond_2
- iget-object v1, p0, Lokhttp3/internal/ws/RealWebSocket;->executor:Ljava/util/concurrent/ScheduledExecutorService;
- invoke-interface {v1}, Ljava/util/concurrent/ScheduledExecutorService;->shutdown()V
- :cond_2
- monitor-exit p0
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_1
- :try_start_1
- iget-object v1, p0, Lokhttp3/internal/ws/RealWebSocket;->listener:Lokhttp3/WebSocketListener;
- invoke-virtual {v1, p0, p1, p2}, Lokhttp3/WebSocketListener;->onFailure(Lokhttp3/WebSocket;Ljava/lang/Throwable;Lokhttp3/Response;)V
- :try_end_1
- .catchall {:try_start_1 .. :try_end_1} :catchall_0
- invoke-static {v0}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
- return-void
- :catchall_0
- move-exception p1
- invoke-static {v0}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
- throw p1
- :catchall_1
- move-exception p1
- :try_start_2
- monitor-exit p0
- :try_end_2
- .catchall {:try_start_2 .. :try_end_2} :catchall_1
- throw p1
- .end method
- .method public initReaderAndWriter(Ljava/lang/String;JLokhttp3/internal/ws/RealWebSocket$Streams;)V
- .locals 7
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- monitor-enter p0
- :try_start_0
- iput-object p4, p0, Lokhttp3/internal/ws/RealWebSocket;->streams:Lokhttp3/internal/ws/RealWebSocket$Streams;
- new-instance v0, Lokhttp3/internal/ws/WebSocketWriter;
- iget-boolean v1, p4, Lokhttp3/internal/ws/RealWebSocket$Streams;->client:Z
- iget-object v2, p4, Lokhttp3/internal/ws/RealWebSocket$Streams;->sink:Lokio/BufferedSink;
- iget-object v3, p0, Lokhttp3/internal/ws/RealWebSocket;->random:Ljava/util/Random;
- invoke-direct {v0, v1, v2, v3}, Lokhttp3/internal/ws/WebSocketWriter;-><init>(ZLokio/BufferedSink;Ljava/util/Random;)V
- iput-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->writer:Lokhttp3/internal/ws/WebSocketWriter;
- new-instance v0, Ljava/util/concurrent/ScheduledThreadPoolExecutor;
- const/4 v1, 0x1
- const/4 v2, 0x0
- invoke-static {p1, v2}, Lokhttp3/internal/Util;->threadFactory(Ljava/lang/String;Z)Ljava/util/concurrent/ThreadFactory;
- move-result-object p1
- invoke-direct {v0, v1, p1}, Ljava/util/concurrent/ScheduledThreadPoolExecutor;-><init>(ILjava/util/concurrent/ThreadFactory;)V
- iput-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->executor:Ljava/util/concurrent/ScheduledExecutorService;
- const-wide/16 v0, 0x0
- cmp-long p1, p2, v0
- if-eqz p1, :cond_0
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->executor:Ljava/util/concurrent/ScheduledExecutorService;
- new-instance v1, Lokhttp3/internal/ws/RealWebSocket$PingRunnable;
- invoke-direct {v1, p0}, Lokhttp3/internal/ws/RealWebSocket$PingRunnable;-><init>(Lokhttp3/internal/ws/RealWebSocket;)V
- sget-object v6, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;
- move-wide v2, p2
- move-wide v4, p2
- invoke-interface/range {v0 .. v6}, Ljava/util/concurrent/ScheduledExecutorService;->scheduleAtFixedRate(Ljava/lang/Runnable;JJLjava/util/concurrent/TimeUnit;)Ljava/util/concurrent/ScheduledFuture;
- :cond_0
- iget-object p1, p0, Lokhttp3/internal/ws/RealWebSocket;->messageAndCloseQueue:Ljava/util/ArrayDeque;
- invoke-virtual {p1}, Ljava/util/ArrayDeque;->isEmpty()Z
- move-result p1
- if-nez p1, :cond_1
- invoke-direct {p0}, Lokhttp3/internal/ws/RealWebSocket;->runWriter()V
- :cond_1
- monitor-exit p0
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_0
- new-instance p1, Lokhttp3/internal/ws/WebSocketReader;
- iget-boolean p2, p4, Lokhttp3/internal/ws/RealWebSocket$Streams;->client:Z
- iget-object p3, p4, Lokhttp3/internal/ws/RealWebSocket$Streams;->source:Lokio/BufferedSource;
- invoke-direct {p1, p2, p3, p0}, Lokhttp3/internal/ws/WebSocketReader;-><init>(ZLokio/BufferedSource;Lokhttp3/internal/ws/WebSocketReader$FrameCallback;)V
- iput-object p1, p0, Lokhttp3/internal/ws/RealWebSocket;->reader:Lokhttp3/internal/ws/WebSocketReader;
- return-void
- :catchall_0
- move-exception p1
- :try_start_1
- monitor-exit p0
- :try_end_1
- .catchall {:try_start_1 .. :try_end_1} :catchall_0
- throw p1
- .end method
- .method public loopReader()V
- .locals 2
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- :goto_0
- iget v0, p0, Lokhttp3/internal/ws/RealWebSocket;->receivedCloseCode:I
- const/4 v1, -0x1
- if-ne v0, v1, :cond_0
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->reader:Lokhttp3/internal/ws/WebSocketReader;
- invoke-virtual {v0}, Lokhttp3/internal/ws/WebSocketReader;->processNextFrame()V
- goto :goto_0
- :cond_0
- return-void
- .end method
- .method public onReadClose(ILjava/lang/String;)V
- .locals 3
- const/4 v0, -0x1
- if-eq p1, v0, :cond_4
- monitor-enter p0
- :try_start_0
- iget v1, p0, Lokhttp3/internal/ws/RealWebSocket;->receivedCloseCode:I
- if-ne v1, v0, :cond_3
- iput p1, p0, Lokhttp3/internal/ws/RealWebSocket;->receivedCloseCode:I
- iput-object p2, p0, Lokhttp3/internal/ws/RealWebSocket;->receivedCloseReason:Ljava/lang/String;
- iget-boolean v0, p0, Lokhttp3/internal/ws/RealWebSocket;->enqueuedClose:Z
- const/4 v1, 0x0
- if-eqz v0, :cond_1
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->messageAndCloseQueue:Ljava/util/ArrayDeque;
- invoke-virtual {v0}, Ljava/util/ArrayDeque;->isEmpty()Z
- move-result v0
- if-eqz v0, :cond_1
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->streams:Lokhttp3/internal/ws/RealWebSocket$Streams;
- iput-object v1, p0, Lokhttp3/internal/ws/RealWebSocket;->streams:Lokhttp3/internal/ws/RealWebSocket$Streams;
- iget-object v1, p0, Lokhttp3/internal/ws/RealWebSocket;->cancelFuture:Ljava/util/concurrent/ScheduledFuture;
- if-eqz v1, :cond_0
- iget-object v1, p0, Lokhttp3/internal/ws/RealWebSocket;->cancelFuture:Ljava/util/concurrent/ScheduledFuture;
- const/4 v2, 0x0
- invoke-interface {v1, v2}, Ljava/util/concurrent/ScheduledFuture;->cancel(Z)Z
- :cond_0
- iget-object v1, p0, Lokhttp3/internal/ws/RealWebSocket;->executor:Ljava/util/concurrent/ScheduledExecutorService;
- invoke-interface {v1}, Ljava/util/concurrent/ScheduledExecutorService;->shutdown()V
- goto :goto_0
- :cond_1
- move-object v0, v1
- :goto_0
- monitor-exit p0
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_1
- :try_start_1
- iget-object v1, p0, Lokhttp3/internal/ws/RealWebSocket;->listener:Lokhttp3/WebSocketListener;
- invoke-virtual {v1, p0, p1, p2}, Lokhttp3/WebSocketListener;->onClosing(Lokhttp3/WebSocket;ILjava/lang/String;)V
- if-eqz v0, :cond_2
- iget-object v1, p0, Lokhttp3/internal/ws/RealWebSocket;->listener:Lokhttp3/WebSocketListener;
- invoke-virtual {v1, p0, p1, p2}, Lokhttp3/WebSocketListener;->onClosed(Lokhttp3/WebSocket;ILjava/lang/String;)V
- :try_end_1
- .catchall {:try_start_1 .. :try_end_1} :catchall_0
- :cond_2
- invoke-static {v0}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
- return-void
- :catchall_0
- move-exception p1
- invoke-static {v0}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
- throw p1
- :cond_3
- :try_start_2
- new-instance p1, Ljava/lang/IllegalStateException;
- const-string p2, "already closed"
- invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
- throw p1
- :catchall_1
- move-exception p1
- monitor-exit p0
- :try_end_2
- .catchall {:try_start_2 .. :try_end_2} :catchall_1
- throw p1
- :cond_4
- new-instance p1, Ljava/lang/IllegalArgumentException;
- invoke-direct {p1}, Ljava/lang/IllegalArgumentException;-><init>()V
- throw p1
- .end method
- .method public onReadMessage(Ljava/lang/String;)V
- .locals 1
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->listener:Lokhttp3/WebSocketListener;
- invoke-virtual {v0, p0, p1}, Lokhttp3/WebSocketListener;->onMessage(Lokhttp3/WebSocket;Ljava/lang/String;)V
- return-void
- .end method
- .method public onReadMessage(Lokio/ByteString;)V
- .locals 1
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->listener:Lokhttp3/WebSocketListener;
- invoke-virtual {v0, p0, p1}, Lokhttp3/WebSocketListener;->onMessage(Lokhttp3/WebSocket;Lokio/ByteString;)V
- return-void
- .end method
- .method public declared-synchronized onReadPing(Lokio/ByteString;)V
- .locals 1
- monitor-enter p0
- :try_start_0
- iget-boolean v0, p0, Lokhttp3/internal/ws/RealWebSocket;->failed:Z
- if-nez v0, :cond_1
- iget-boolean v0, p0, Lokhttp3/internal/ws/RealWebSocket;->enqueuedClose:Z
- if-eqz v0, :cond_0
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->messageAndCloseQueue:Ljava/util/ArrayDeque;
- invoke-virtual {v0}, Ljava/util/ArrayDeque;->isEmpty()Z
- move-result v0
- if-eqz v0, :cond_0
- goto :goto_0
- :cond_0
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->pongQueue:Ljava/util/ArrayDeque;
- invoke-virtual {v0, p1}, Ljava/util/ArrayDeque;->add(Ljava/lang/Object;)Z
- invoke-direct {p0}, Lokhttp3/internal/ws/RealWebSocket;->runWriter()V
- iget p1, p0, Lokhttp3/internal/ws/RealWebSocket;->pingCount:I
- add-int/lit8 p1, p1, 0x1
- iput p1, p0, Lokhttp3/internal/ws/RealWebSocket;->pingCount:I
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_0
- monitor-exit p0
- return-void
- :cond_1
- :goto_0
- monitor-exit p0
- return-void
- :catchall_0
- move-exception p1
- monitor-exit p0
- throw p1
- .end method
- .method public declared-synchronized onReadPong(Lokio/ByteString;)V
- .locals 0
- monitor-enter p0
- :try_start_0
- iget p1, p0, Lokhttp3/internal/ws/RealWebSocket;->pongCount:I
- add-int/lit8 p1, p1, 0x1
- iput p1, p0, Lokhttp3/internal/ws/RealWebSocket;->pongCount:I
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_0
- monitor-exit p0
- return-void
- :catchall_0
- move-exception p1
- monitor-exit p0
- throw p1
- .end method
- .method declared-synchronized pingCount()I
- .locals 1
- monitor-enter p0
- :try_start_0
- iget v0, p0, Lokhttp3/internal/ws/RealWebSocket;->pingCount:I
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_0
- monitor-exit p0
- return v0
- :catchall_0
- move-exception v0
- monitor-exit p0
- throw v0
- .end method
- .method declared-synchronized pong(Lokio/ByteString;)Z
- .locals 1
- monitor-enter p0
- :try_start_0
- iget-boolean v0, p0, Lokhttp3/internal/ws/RealWebSocket;->failed:Z
- if-nez v0, :cond_1
- iget-boolean v0, p0, Lokhttp3/internal/ws/RealWebSocket;->enqueuedClose:Z
- if-eqz v0, :cond_0
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->messageAndCloseQueue:Ljava/util/ArrayDeque;
- invoke-virtual {v0}, Ljava/util/ArrayDeque;->isEmpty()Z
- move-result v0
- if-eqz v0, :cond_0
- goto :goto_1
- :cond_0
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->pongQueue:Ljava/util/ArrayDeque;
- invoke-virtual {v0, p1}, Ljava/util/ArrayDeque;->add(Ljava/lang/Object;)Z
- invoke-direct {p0}, Lokhttp3/internal/ws/RealWebSocket;->runWriter()V
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_0
- const/4 p1, 0x1
- :goto_0
- monitor-exit p0
- return p1
- :cond_1
- :goto_1
- const/4 p1, 0x0
- goto :goto_0
- :catchall_0
- move-exception p1
- monitor-exit p0
- goto :goto_3
- :goto_2
- throw p1
- :goto_3
- goto :goto_2
- .end method
- .method declared-synchronized pongCount()I
- .locals 1
- monitor-enter p0
- :try_start_0
- iget v0, p0, Lokhttp3/internal/ws/RealWebSocket;->pongCount:I
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_0
- monitor-exit p0
- return v0
- :catchall_0
- move-exception v0
- monitor-exit p0
- throw v0
- .end method
- .method processNextFrame()Z
- .locals 3
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- const/4 v0, 0x0
- :try_start_0
- iget-object v1, p0, Lokhttp3/internal/ws/RealWebSocket;->reader:Lokhttp3/internal/ws/WebSocketReader;
- invoke-virtual {v1}, Lokhttp3/internal/ws/WebSocketReader;->processNextFrame()V
- iget v1, p0, Lokhttp3/internal/ws/RealWebSocket;->receivedCloseCode:I
- :try_end_0
- .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0
- const/4 v2, -0x1
- if-ne v1, v2, :cond_0
- const/4 v0, 0x1
- :cond_0
- return v0
- :catch_0
- move-exception v1
- const/4 v2, 0x0
- invoke-virtual {p0, v1, v2}, Lokhttp3/internal/ws/RealWebSocket;->failWebSocket(Ljava/lang/Exception;Lokhttp3/Response;)V
- return v0
- .end method
- .method public declared-synchronized queueSize()J
- .locals 2
- monitor-enter p0
- :try_start_0
- iget-wide v0, p0, Lokhttp3/internal/ws/RealWebSocket;->queueSize:J
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_0
- monitor-exit p0
- return-wide v0
- :catchall_0
- move-exception v0
- monitor-exit p0
- throw v0
- .end method
- .method public request()Lokhttp3/Request;
- .locals 1
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->originalRequest:Lokhttp3/Request;
- return-object v0
- .end method
- .method public send(Ljava/lang/String;)Z
- .locals 1
- if-eqz p1, :cond_0
- invoke-static {p1}, Lokio/ByteString;->encodeUtf8(Ljava/lang/String;)Lokio/ByteString;
- move-result-object p1
- const/4 v0, 0x1
- invoke-direct {p0, p1, v0}, Lokhttp3/internal/ws/RealWebSocket;->send(Lokio/ByteString;I)Z
- move-result p1
- return p1
- :cond_0
- new-instance p1, Ljava/lang/NullPointerException;
- const-string v0, "text == null"
- invoke-direct {p1, v0}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V
- throw p1
- .end method
- .method public send(Lokio/ByteString;)Z
- .locals 1
- if-eqz p1, :cond_0
- const/4 v0, 0x2
- invoke-direct {p0, p1, v0}, Lokhttp3/internal/ws/RealWebSocket;->send(Lokio/ByteString;I)Z
- move-result p1
- return p1
- :cond_0
- new-instance p1, Ljava/lang/NullPointerException;
- const-string v0, "bytes == null"
- invoke-direct {p1, v0}, Ljava/lang/NullPointerException;-><init>(Ljava/lang/String;)V
- throw p1
- .end method
- .method tearDown()V
- .locals 4
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/lang/InterruptedException;
- }
- .end annotation
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->cancelFuture:Ljava/util/concurrent/ScheduledFuture;
- if-eqz v0, :cond_0
- const/4 v1, 0x0
- invoke-interface {v0, v1}, Ljava/util/concurrent/ScheduledFuture;->cancel(Z)Z
- :cond_0
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->executor:Ljava/util/concurrent/ScheduledExecutorService;
- invoke-interface {v0}, Ljava/util/concurrent/ScheduledExecutorService;->shutdown()V
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->executor:Ljava/util/concurrent/ScheduledExecutorService;
- const-wide/16 v1, 0xa
- sget-object v3, Ljava/util/concurrent/TimeUnit;->SECONDS:Ljava/util/concurrent/TimeUnit;
- invoke-interface {v0, v1, v2, v3}, Ljava/util/concurrent/ScheduledExecutorService;->awaitTermination(JLjava/util/concurrent/TimeUnit;)Z
- return-void
- .end method
- .method writeOneFrame()Z
- .locals 11
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- monitor-enter p0
- :try_start_0
- iget-boolean v0, p0, Lokhttp3/internal/ws/RealWebSocket;->failed:Z
- const/4 v1, 0x0
- if-eqz v0, :cond_0
- monitor-exit p0
- return v1
- :cond_0
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->writer:Lokhttp3/internal/ws/WebSocketWriter;
- iget-object v2, p0, Lokhttp3/internal/ws/RealWebSocket;->pongQueue:Ljava/util/ArrayDeque;
- invoke-virtual {v2}, Ljava/util/ArrayDeque;->poll()Ljava/lang/Object;
- move-result-object v2
- check-cast v2, Lokio/ByteString;
- const/4 v3, -0x1
- const/4 v4, 0x0
- if-nez v2, :cond_4
- iget-object v5, p0, Lokhttp3/internal/ws/RealWebSocket;->messageAndCloseQueue:Ljava/util/ArrayDeque;
- invoke-virtual {v5}, Ljava/util/ArrayDeque;->poll()Ljava/lang/Object;
- move-result-object v5
- instance-of v6, v5, Lokhttp3/internal/ws/RealWebSocket$Close;
- if-eqz v6, :cond_2
- iget v1, p0, Lokhttp3/internal/ws/RealWebSocket;->receivedCloseCode:I
- iget-object v6, p0, Lokhttp3/internal/ws/RealWebSocket;->receivedCloseReason:Ljava/lang/String;
- if-eq v1, v3, :cond_1
- iget-object v3, p0, Lokhttp3/internal/ws/RealWebSocket;->streams:Lokhttp3/internal/ws/RealWebSocket$Streams;
- iput-object v4, p0, Lokhttp3/internal/ws/RealWebSocket;->streams:Lokhttp3/internal/ws/RealWebSocket$Streams;
- iget-object v4, p0, Lokhttp3/internal/ws/RealWebSocket;->executor:Ljava/util/concurrent/ScheduledExecutorService;
- invoke-interface {v4}, Ljava/util/concurrent/ScheduledExecutorService;->shutdown()V
- move-object v4, v3
- goto :goto_1
- :cond_1
- iget-object v3, p0, Lokhttp3/internal/ws/RealWebSocket;->executor:Ljava/util/concurrent/ScheduledExecutorService;
- new-instance v7, Lokhttp3/internal/ws/RealWebSocket$CancelRunnable;
- invoke-direct {v7, p0}, Lokhttp3/internal/ws/RealWebSocket$CancelRunnable;-><init>(Lokhttp3/internal/ws/RealWebSocket;)V
- move-object v8, v5
- check-cast v8, Lokhttp3/internal/ws/RealWebSocket$Close;
- iget-wide v8, v8, Lokhttp3/internal/ws/RealWebSocket$Close;->cancelAfterCloseMillis:J
- sget-object v10, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;
- invoke-interface {v3, v7, v8, v9, v10}, Ljava/util/concurrent/ScheduledExecutorService;->schedule(Ljava/lang/Runnable;JLjava/util/concurrent/TimeUnit;)Ljava/util/concurrent/ScheduledFuture;
- move-result-object v3
- iput-object v3, p0, Lokhttp3/internal/ws/RealWebSocket;->cancelFuture:Ljava/util/concurrent/ScheduledFuture;
- goto :goto_1
- :cond_2
- if-nez v5, :cond_3
- monitor-exit p0
- return v1
- :cond_3
- move-object v6, v4
- goto :goto_0
- :cond_4
- move-object v5, v4
- move-object v6, v5
- :goto_0
- const/4 v1, -0x1
- :goto_1
- monitor-exit p0
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_2
- if-eqz v2, :cond_5
- :try_start_1
- invoke-virtual {v0, v2}, Lokhttp3/internal/ws/WebSocketWriter;->writePong(Lokio/ByteString;)V
- goto :goto_2
- :cond_5
- instance-of v2, v5, Lokhttp3/internal/ws/RealWebSocket$Message;
- if-eqz v2, :cond_6
- move-object v1, v5
- check-cast v1, Lokhttp3/internal/ws/RealWebSocket$Message;
- iget-object v1, v1, Lokhttp3/internal/ws/RealWebSocket$Message;->data:Lokio/ByteString;
- check-cast v5, Lokhttp3/internal/ws/RealWebSocket$Message;
- iget v2, v5, Lokhttp3/internal/ws/RealWebSocket$Message;->formatOpcode:I
- invoke-virtual {v1}, Lokio/ByteString;->size()I
- move-result v3
- int-to-long v5, v3
- invoke-virtual {v0, v2, v5, v6}, Lokhttp3/internal/ws/WebSocketWriter;->newMessageSink(IJ)Lokio/Sink;
- move-result-object v0
- invoke-static {v0}, Lokio/Okio;->buffer(Lokio/Sink;)Lokio/BufferedSink;
- move-result-object v0
- invoke-interface {v0, v1}, Lokio/BufferedSink;->write(Lokio/ByteString;)Lokio/BufferedSink;
- invoke-interface {v0}, Lokio/Sink;->close()V
- monitor-enter p0
- :try_end_1
- .catchall {:try_start_1 .. :try_end_1} :catchall_1
- :try_start_2
- iget-wide v2, p0, Lokhttp3/internal/ws/RealWebSocket;->queueSize:J
- invoke-virtual {v1}, Lokio/ByteString;->size()I
- move-result v0
- int-to-long v0, v0
- sub-long/2addr v2, v0
- iput-wide v2, p0, Lokhttp3/internal/ws/RealWebSocket;->queueSize:J
- monitor-exit p0
- goto :goto_2
- :catchall_0
- move-exception v0
- monitor-exit p0
- :try_end_2
- .catchall {:try_start_2 .. :try_end_2} :catchall_0
- :try_start_3
- throw v0
- :cond_6
- instance-of v2, v5, Lokhttp3/internal/ws/RealWebSocket$Close;
- if-eqz v2, :cond_8
- check-cast v5, Lokhttp3/internal/ws/RealWebSocket$Close;
- iget v2, v5, Lokhttp3/internal/ws/RealWebSocket$Close;->code:I
- iget-object v3, v5, Lokhttp3/internal/ws/RealWebSocket$Close;->reason:Lokio/ByteString;
- invoke-virtual {v0, v2, v3}, Lokhttp3/internal/ws/WebSocketWriter;->writeClose(ILokio/ByteString;)V
- if-eqz v4, :cond_7
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->listener:Lokhttp3/WebSocketListener;
- invoke-virtual {v0, p0, v1, v6}, Lokhttp3/WebSocketListener;->onClosed(Lokhttp3/WebSocket;ILjava/lang/String;)V
- :try_end_3
- .catchall {:try_start_3 .. :try_end_3} :catchall_1
- :cond_7
- :goto_2
- const/4 v0, 0x1
- invoke-static {v4}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
- return v0
- :cond_8
- :try_start_4
- new-instance v0, Ljava/lang/AssertionError;
- invoke-direct {v0}, Ljava/lang/AssertionError;-><init>()V
- throw v0
- :try_end_4
- .catchall {:try_start_4 .. :try_end_4} :catchall_1
- :catchall_1
- move-exception v0
- invoke-static {v4}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
- throw v0
- :catchall_2
- move-exception v0
- :try_start_5
- monitor-exit p0
- :try_end_5
- .catchall {:try_start_5 .. :try_end_5} :catchall_2
- throw v0
- .end method
- .method writePingFrame()V
- .locals 2
- monitor-enter p0
- :try_start_0
- iget-boolean v0, p0, Lokhttp3/internal/ws/RealWebSocket;->failed:Z
- if-eqz v0, :cond_0
- monitor-exit p0
- return-void
- :cond_0
- iget-object v0, p0, Lokhttp3/internal/ws/RealWebSocket;->writer:Lokhttp3/internal/ws/WebSocketWriter;
- monitor-exit p0
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_0
- :try_start_1
- sget-object v1, Lokio/ByteString;->EMPTY:Lokio/ByteString;
- invoke-virtual {v0, v1}, Lokhttp3/internal/ws/WebSocketWriter;->writePing(Lokio/ByteString;)V
- :try_end_1
- .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_0
- goto :goto_0
- :catch_0
- move-exception v0
- const/4 v1, 0x0
- invoke-virtual {p0, v0, v1}, Lokhttp3/internal/ws/RealWebSocket;->failWebSocket(Ljava/lang/Exception;Lokhttp3/Response;)V
- :goto_0
- return-void
- :catchall_0
- move-exception v0
- :try_start_2
- monitor-exit p0
- :try_end_2
- .catchall {:try_start_2 .. :try_end_2} :catchall_0
- throw v0
- .end method
|