zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
U
[±daÝã@s”ddlZddlmZddlmZddlmZddlmZddl    Z    ddl
Z
ddl Z ddl Z ddl Z ddlZddlmZmZddlZddlZddlmZddlmZmZdd    lmZddlmZdd
lm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(ddl)Ze*e+e,ej- .d ¡ƒƒd kZ/d Z0dZ1dZ2dZ3e
 4d¡Z5dd„Z6Gdd„dƒZ7edde1e2e0e0dœdd„ƒZ8dde1e2dœdd„Z9dAdde1e2e0e0dœdd„Z:dBdde1e2dœdd„Z;d d!„Z<dde1e2dœd"d#„Z=e1e2fd$d%„Z>de1e2e0e0ej?d&œd'd(„Z@Gd)d*„d*eAƒZBGd+d,„d,eBƒZCGd-d.„d.eBƒZDGd/d0„d0eAƒZEGd1d2„d2eBƒZFGd3d4„d4ƒZGGd5d6„d6ƒZHGd7d8„d8ƒZId9d:„ZJGd;d<„d<ejKjLƒZMGd=d>„d>ƒZNGd?d@„d@ƒZOdS)CéN)Ú OrderedDict)Úasynccontextmanager)Úpartial)Ú
ip_address)ÚListÚOptional)ÚBaseExceptionGroup)ÚConnectionTypeÚ WSConnection)ÚConnectionState)    ÚAcceptConnectionÚ BytesMessageÚCloseConnectionÚPingÚPongÚRejectConnectionÚ
RejectDataÚRequestÚ TextMessageÚ.)réré<éiiztrio-websocketcCst|tjƒrdS|S©N©Ú
isinstanceÚtrioZ    Cancelled©Úexc©rúKd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\trio_websocket/_impl.pyÚ_ignore_cancel*sr!c@s,eZdZdZdZdd„Zdd„Zdd„Zd    S)
Ú_preserve_current_exceptionaœA context manager which should surround an ``__exit__`` or
    ``__aexit__`` handler or the contents of a ``finally:``
    block. It ensures that any exception that was being handled
    upon entry is not masked by a `trio.Cancelled` raised within
    the body of the context manager.
 
    https://github.com/python-trio/trio/issues/1559
    https://gitter.im/python-trio/general?at=5faf2293d37a1a13d6a582cf
    ©Ú_armedcCs
d|_dS©NFr#©Úselfrrr Ú__init__:sz$_preserve_current_exception.__init__cCst ¡ddk    |_dS)Nr)ÚsysÚexc_infor$r&rrr Ú    __enter__=sz%_preserve_current_exception.__enter__cCsP|dks|jsdStr&tj t|¡}n"t|tƒr@| dd„¡}nt|ƒ}|dkS)NFcSst|tjƒ Srrrrrr Ú<lambda>Góz6_preserve_current_exception.__exit__.<locals>.<lambda>)    r$Ú_TRIO_MULTI_ERRORrZ
MultiErrorÚfilterr!rrZsubgroup)r'ÚtyÚvalueÚtbZfiltered_exceptionrrr Ú__exit__@s
z$_preserve_current_exception.__exit__N)Ú__name__Ú
__module__Ú __qualname__Ú__doc__Ú    __slots__r(r+r3rrrr r".s
    r")Ú subprotocolsÚ extra_headersÚmessage_queue_sizeÚmax_message_sizeÚconnect_timeoutÚdisconnect_timeoutc Csøt ¡4IdHšØ}
z:t |¡&t|
||||||||d    IdH} W5QRXWnBtjk
rhtd‚Yn(tk
rŽ} z
t| ‚W5d} ~ XYnXz
| VW5z(t |    ¡|  ¡IdHW5QRXWntjk
ràt    d‚YnXXW5QIdHRXdS)aÇ
    Open a WebSocket client connection to a host.
 
    This async context manager connects when entering the context manager and
    disconnects when exiting. It yields a
    :class:`WebSocketConnection` instance.
 
    :param str host: The host to connect to.
    :param int port: The port to connect to.
    :param str resource: The resource, i.e. URL path.
    :param Union[bool, ssl.SSLContext] use_ssl: If this is an SSL context, then
        use that context. If this is ``True`` then use default SSL context. If
        this is ``False`` then disable SSL.
    :param subprotocols: An iterable of strings representing preferred
        subprotocols.
    :param list[tuple[bytes,bytes]] extra_headers: A list of 2-tuples containing
        HTTP header key/value pairs to send with the connection request. Note
        that headers used by the WebSocket protocol (e.g.
        ``Sec-WebSocket-Accept``) will be overwritten.
    :param int message_queue_size: The maximum number of messages that will be
        buffered in the library's internal message queue.
    :param int max_message_size: The maximum message size as measured by
        ``len()``. If a message is received that is larger than this size,
        then the connection is closed with code 1009 (Message Too Big).
    :param float connect_timeout: The number of seconds to wait for the
        connection before timing out.
    :param float disconnect_timeout: The number of seconds to wait when closing
        the connection before timing out.
    :raises HandshakeError: for any networking error,
        client-side timeout (:exc:`ConnectionTimeout`, :exc:`DisconnectionTimeout`),
        or server rejection (:exc:`ConnectionRejected`) during handshakes.
    N©Úuse_sslr9r:r;r<)
rÚ open_nurseryZ
fail_afterÚconnect_websocketZ TooSlowErrorÚConnectionTimeoutÚOSErrorÚHandshakeErrorÚacloseÚDisconnectionTimeout) ÚhostÚportÚresourcer@r9r:r;r<r=r>Z new_nurseryÚ
connectionÚerrr Úopen_websocketMs,% ü
 
 rM)r9r:r;r<c
Ãsæ|dkrt ¡}    n(|dkr d}    nt|tjƒr2|}    ntdƒ‚t d|    dkrLdnd|||¡|    dkrtt ||¡IdH}
ntj    |||    ddIdH}
|d    krš|} n|›d
|›} t
|
t t j ƒ| |||||d } | | j¡| j ¡IdH| S) aÉ
    Return an open WebSocket client connection to a host.
 
    This function is used to specify a custom nursery to run connection
    background tasks in. The caller is responsible for closing the connection.
 
    If you don't need a custom nursery, you should probably use
    :func:`open_websocket` instead.
 
    :param nursery: A Trio nursery to run background tasks in.
    :param str host: The host to connect to.
    :param int port: The port to connect to.
    :param str resource: The resource, i.e. URL path.
    :param Union[bool, ssl.SSLContext] use_ssl: If this is an SSL context, then
        use that context. If this is ``True`` then use default SSL context. If
        this is ``False`` then disable SSL.
    :param subprotocols: An iterable of strings representing preferred
        subprotocols.
    :param list[tuple[bytes,bytes]] extra_headers: A list of 2-tuples containing
        HTTP header key/value pairs to send with the connection request. Note
        that headers used by the WebSocket protocol (e.g.
        ``Sec-WebSocket-Accept``) will be overwritten.
    :param int message_queue_size: The maximum number of messages that will be
        buffered in the library's internal message queue.
    :param int max_message_size: The maximum message size as measured by
        ``len()``. If a message is received that is larger than this size,
        then the connection is closed with code 1009 (Message Too Big).
    :rtype: WebSocketConnection
    TFNz1`use_ssl` argument must be bool or ssl.SSLContextzConnecting to ws%s://%s:%d%sÚÚs)Ú ssl_contextÚhttps_compatible)éPé»ú:©rHÚpathÚclient_subprotocolsÚclient_extra_headersr;r<)ÚsslÚcreate_default_contextrÚ
SSLContextÚ    TypeErrorÚloggerÚdebugrZopen_tcp_streamZopen_ssl_over_tcp_streamÚWebSocketConnectionr
r    ÚCLIENTÚ
start_soonÚ _reader_taskÚ_open_handshakeÚwait) ÚnurseryrHrIrJr@r9r:r;r<rPÚstreamZ host_headerrKrrr rBˆsD 
 ÿÿ ú rBc Cs.t||ƒ\}}    }
}t||    |
|||||||d
S)au
    Open a WebSocket client connection to a URL.
 
    This async context manager connects when entering the context manager and
    disconnects when exiting. It yields a
    :class:`WebSocketConnection` instance.
 
    :param str url: A WebSocket URL, i.e. `ws:` or `wss:` URL scheme.
    :param ssl_context: Optional SSL context used for ``wss:`` URLs. A default
        SSL context is used for ``wss:`` if this argument is ``None``.
    :type ssl_context: ssl.SSLContext or None
    :param subprotocols: An iterable of strings representing preferred
        subprotocols.
    :param list[tuple[bytes,bytes]] extra_headers: A list of 2-tuples containing
        HTTP header key/value pairs to send with the connection request. Note
        that headers used by the WebSocket protocol (e.g.
        ``Sec-WebSocket-Accept``) will be overwritten.
    :param int message_queue_size: The maximum number of messages that will be
        buffered in the library's internal message queue.
    :param int max_message_size: The maximum message size as measured by
        ``len()``. If a message is received that is larger than this size,
        then the connection is closed with code 1009 (Message Too Big).
    :param float connect_timeout: The number of seconds to wait for the
        connection before timing out.
    :param float disconnect_timeout: The number of seconds to wait when closing
        the connection before timing out.
    :raises HandshakeError: for any networking error,
        client-side timeout (:exc:`ConnectionTimeout`, :exc:`DisconnectionTimeout`),
        or server rejection (:exc:`ConnectionRejected`) during handshakes.
    )r@r9r:r;r<r=r>)Ú _url_to_hostrM) ÚurlrPr9r:r;r<r=r>rHrIrJrrr Úopen_websocket_urlÈs"
üric
Ãs2t||ƒ\}}}    }t||||    |||||d    IdHS)a
    Return an open WebSocket client connection to a URL.
 
    This function is used to specify a custom nursery to run connection
    background tasks in. The caller is responsible for closing the connection.
 
    If you don't need a custom nursery, you should probably use
    :func:`open_websocket_url` instead.
 
    :param nursery: A nursery to run background tasks in.
    :param str url: A WebSocket URL.
    :param ssl_context: Optional SSL context used for ``wss:`` URLs.
    :type ssl_context: ssl.SSLContext or None
    :param subprotocols: An iterable of strings representing preferred
        subprotocols.
    :param list[tuple[bytes,bytes]] extra_headers: A list of 2-tuples containing
        HTTP header key/value pairs to send with the connection request. Note
        that headers used by the WebSocket protocol (e.g.
        ``Sec-WebSocket-Accept``) will be overwritten.
    :param int message_queue_size: The maximum number of messages that will be
        buffered in the library's internal message queue.
    :param int max_message_size: The maximum message size as measured by
        ``len()``. If a message is received that is larger than this size,
        then the connection is closed with code 1009 (Message Too Big).
    :rtype: WebSocketConnection
    r?N)rgrB)
rerhrPr9r:r;r<rHrIrJrrr Úconnect_websocket_urlòs
ýrjcCs t|ƒ}tj |¡}|jdkr&tdƒ‚|dkr:|jdk}n|jdkrLtdƒ‚|j}|jdk    rd|j}n |rldnd}|j}|s~d    }d
|kr”|d
|j    7}||||fS) a”
    Convert a WebSocket URL to a (host,port,resource) tuple.
 
    The returned ``ssl_context`` is either the same object that was passed in,
    or if ``ssl_context`` is None, then a bool indicating if a default SSL
    context needs to be created.
 
    :param str url: A WebSocket URL.
    :type ssl_context: ssl.SSLContext or None
    :returns: A tuple of ``(host, port, resource, ssl_context)``.
    )ÚwsÚwssz,WebSocket URL scheme must be "ws:" or "wss:"Nrlrkz+SSL context must be None for ws: URL schemerSrRú/ú?)
ÚstrÚurllibÚparseÚurlsplitÚschemeÚ
ValueErrorÚhostnamerIrVÚquery)rhrPÚpartsrHrIZpath_qsrrr rgs$  
 
 
 rgc    
Ãs>t|ttjƒ||||||d}| |j¡|j ¡IdH|S)a
    Wrap an arbitrary stream in a WebSocket connection.
 
    This is a low-level function only needed in rare cases. In most cases, you
    should use :func:`open_websocket` or :func:`open_websocket_url`.
 
    :param nursery: A Trio nursery to run background tasks in.
    :param stream: A Trio stream to be wrapped.
    :type stream: trio.abc.Stream
    :param str host: A host string that will be sent in the ``Host:`` header.
    :param str resource: A resource string, i.e. the path component to be
        accessed on the server.
    :param subprotocols: An iterable of strings representing preferred
        subprotocols.
    :param list[tuple[bytes,bytes]] extra_headers: A list of 2-tuples containing
        HTTP header key/value pairs to send with the connection request. Note
        that headers used by the WebSocket protocol (e.g.
        ``Sec-WebSocket-Accept``) will be overwritten.
    :param int message_queue_size: The maximum number of messages that will be
        buffered in the library's internal message queue.
    :param int max_message_size: The maximum message size as measured by
        ``len()``. If a message is received that is larger than this size,
        then the connection is closed with code 1009 (Message Too Big).
    :rtype: WebSocketConnection
    rUN)r_r
r    r`rarbrcrd)    rerfrHrJr9r:r;r<rKrrr Úwrap_client_stream:sû rxcÃs4t|ttjƒ||d}| |j¡| ¡IdH}|S)aÀ
    Wrap an arbitrary stream in a server-side WebSocket.
 
    This is a low-level function only needed in rare cases. In most cases, you
    should use :func:`serve_websocket`.
 
    :param nursery: A nursery to run background tasks in.
    :param stream: A stream to be wrapped.
    :param int message_queue_size: The maximum number of messages that will be
        buffered in the library's internal message queue.
    :param int max_message_size: The maximum message size as measured by
        ``len()``. If a message is received that is larger than this size,
        then the connection is closed with code 1009 (Message Too Big).
    :type stream: trio.abc.Stream
    :rtype: WebSocketRequest
    ©r;r<N)r_r
r    ÚSERVERrarbÚ _get_request)rerfr;r<rKÚrequestrrr Úwrap_server_streamasý r})Úhandler_nurseryr;r<r=r>Ú task_statusc     Ãsf|dkrttj||d}
nttj|||dd}
|
ƒIdH} t|| |||||d} | j|    dIdHdS)už
    Serve a WebSocket over TCP.
 
    This function supports the Trio nursery start protocol: ``server = await
    nursery.start(serve_websocket, â€¦)``. It will block until the server
    is accepting connections and then return a :class:`WebSocketServer` object.
 
    Note that if ``host`` is ``None`` and ``port`` is zero, then you may get
    multiple listeners that have *different port numbers!*
 
    :param handler: An async function that is invoked with a request
        for each new connection.
    :param host: The host interface to bind. This can be an address of an
        interface, a name that resolves to an interface address (e.g.
        ``localhost``), or a wildcard address like ``0.0.0.0`` for IPv4 or
        ``::`` for IPv6. If ``None``, then all local interfaces are bound.
    :type host: str, bytes, or None
    :param int port: The port to bind to.
    :param ssl_context: The SSL context to use for encrypted connections, or
        ``None`` for unencrypted connection.
    :type ssl_context: ssl.SSLContext or None
    :param handler_nursery: An optional nursery to spawn handlers and background
        tasks in. If not specified, a new nursery will be created internally.
    :param int message_queue_size: The maximum number of messages that will be
        buffered in the library's internal message queue.
    :param int max_message_size: The maximum message size as measured by
        ``len()``. If a message is received that is larger than this size,
        then the connection is closed with code 1009 (Message Too Big).
    :param float connect_timeout: The number of seconds to wait for a client
        to finish connection handshake before timing out.
    :param float disconnect_timeout: The number of seconds to wait for a client
        to finish the closing handshake before timing out.
    :param task_status: Part of Trio nursery start protocol.
    :returns: This function runs until cancelled.
    N)rHT)rHrQ©r~r;r<r=r>©r)rrÚopen_tcp_listenersZopen_ssl_over_tcp_listenersÚWebSocketServerÚrun) ÚhandlerrHrIrPr~r;r<r=r>rr‚Ú    listenersÚserverrrr Úserve_websocket|s 'ÿ ýrˆc@seZdZdZdS)rEz^
    There was an error during connection or disconnection with the websocket
    server.
    N©r4r5r6r7rrrr rE°srEc@seZdZdZdS)rCz<There was a timeout when connecting to the websocket server.Nr‰rrrr rC¶srCc@seZdZdZdS)rGzAThere was a timeout when disconnecting from the websocket server.Nr‰rrrr rG¹srGcs(eZdZdZ‡fdd„Zdd„Z‡ZS)ÚConnectionClosedzv
    A WebSocket operation cannot be completed because the connection is closed
    or in the process of closing.
    cstƒ ¡||_dS©zX
        Constructor.
 
        :param reason:
        :type reason: CloseReason
        N)Úsuperr(Úreason)r'r©Ú    __class__rr r(Ás
zConnectionClosed.__init__cCs|jj›d|j›dS)ú Return representation. ú<ú>)rr4rr&rrr Ú__repr__ËszConnectionClosed.__repr__©r4r5r6r7r(r“Ú __classcell__rrrŽr rмs
rŠcs(eZdZdZ‡fdd„Zdd„Z‡ZS)ÚConnectionRejectedzq
    A WebSocket connection could not be established because the server rejected
    the connection attempt.
    cs tƒ ¡||_||_||_dSr‹)rŒr(Ú status_codeÚheadersÚbody)r'r—r˜r™rŽrr r(Õs
zConnectionRejected.__init__cCs|jj›d|j›dS)rz <status_code=r’)rr4r—r&rrr r“äszConnectionRejected.__repr__r”rrrŽr r–Ðs r–c@sDeZdZdZdd„Zedd„ƒZedd„ƒZedd    „ƒZd
d „Z    d S) Ú CloseReasonz8 Contains information about why a WebSocket was closed. cCsž||_zt |¡j|_Wnztk
r’d|kr<dkrHnnd|_nFd|kr\dkrhnnd|_n&d|kr|dkrˆnnd    |_nd
|_YnX||_d S) z]
        Constructor.
 
        :param int code:
        :param Optional[str] reason:
        éèi· Z RFC_RESERVEDi¸ iŸZ IANA_RESERVEDi i‡ZPRIVATE_RESERVEDZ INVALID_CODEN)Ú_codeÚ wsframeprotoršÚnameÚ_namertÚ_reason©r'Úcoderrrr r(ës zCloseReason.__init__cCs|jS)z% (Read-only) The numeric close code. )rœr&rrr r¢szCloseReason.codecCs|jS)z, (Read-only) The human-readable close code. )rŸr&rrr ržszCloseReason.namecCs|jS)z) (Read-only) An arbitrary reason string. )r r&rrr r
szCloseReason.reasoncCs&|jj›d|j›d|j›d|j›dS)z$ Show close code, name, and reason. z<code=z, name=z    , reason=r’)rr4r¢ržrr&rrr r“szCloseReason.__repr__N)
r4r5r6r7r(Úpropertyr¢ržrr“rrrr ršés
 
 
ršc@s(eZdZdZdd„Zdd„Zdd„ZdS)    ÚFuturez: Represents a value that will be available in the future. cCsd|_t ¡|_dS)z Constructor. N)Ú_valuerÚEventÚ _value_eventr&rrr r(szFuture.__init__cCs||_|j ¡dS)zT
        Set a value, which will notify any waiters.
 
        :param value:
        N)r¥r§Úset)r'r1rrr Ú    set_valueszFuture.set_valuecÃs|j ¡IdH|jS)z|
        Wait for this future to have a value, then return it.
 
        :returns: The value set by ``set_value()``.
        N)r§rdr¥r&rrr Ú
wait_value%szFuture.wait_valueN)r4r5r6r7r(r©rªrrrr r¤s    r¤c@steZdZdZdd„Zedd„ƒZedd„ƒZedd    „ƒZed
d „ƒZ    ed d „ƒZ
dddœdd„Z dddœdd„Z dS)ÚWebSocketRequestzß
    Represents a handshake presented by a client to a server.
 
    The server may modify the handshake or leave it as is. The server should
    call ``accept()`` to finish the handshake and obtain a connection object.
    cCs||_||_dS)zz
        Constructor.
 
        :param WebSocketConnection connection:
        :type event: wsproto.events.Request
        N)Ú _connectionÚ_event)r'rKÚeventrrr r(6szWebSocketRequest.__init__cCs|jjS)zi
        HTTP headers represented as a list of (name, value) pairs.
 
        :rtype: list[tuple]
        )r­r:r&rrr r˜@szWebSocketRequest.headerscCs|jjS)z>
        The requested URL path.
 
        :rtype: str
        )r­Útargetr&rrr rVIszWebSocketRequest.pathcCs t|jjƒS)zZ
        A tuple of protocols proposed by the client.
 
        :rtype: tuple[str]
        )Útupler­r9r&rrr Úproposed_subprotocolsRsz&WebSocketRequest.proposed_subprotocolscCs|jjS)zS
        The connection's local endpoint.
 
        :rtype: Endpoint or str
        )r¬Úlocalr&rrr r²[szWebSocketRequest.localcCs|jjS)zT
        The connection's remote endpoint.
 
        :rtype: Endpoint or str
        )r¬Úremoter&rrr r³dszWebSocketRequest.remoteN©Ú subprotocolr:cÃs*|dkr g}|j |j||¡IdH|jS)a‰
        Accept the request and return a connection object.
 
        :param subprotocol: The selected subprotocol for this connection.
        :type subprotocol: str or None
        :param extra_headers: A list of 2-tuples containing key/value pairs to
            send as HTTP headers.
        :type extra_headers: list[tuple[bytes,bytes]] or None
        :rtype: WebSocketConnection
        N)r¬Ú_acceptr­)r'rµr:rrr Úacceptms zWebSocketRequest.accept)r:r™cÃs*|pg}|pd}|j |||¡IdHdS)a#
        Reject the handshake.
 
        :param int status_code: The 3 digit HTTP status code. In order to be
            RFC-compliant, this should NOT be 101, and would ideally be an
            appropriate code in the range 300-599.
        :param list[tuple[bytes,bytes]] extra_headers: A list of 2-tuples
            containing key/value pairs to send as HTTP headers.
        :param body: If provided, this data will be sent in the response
            body, otherwise no response body will be sent.
        :type body: bytes or None
        r-N)r¬Ú_reject)r'r—r:r™rrr Úreject}s zWebSocketRequest.reject) r4r5r6r7r(r£r˜rVr±r²r³r·r¹rrrr r«/s
 
 
 
 
 
r«cCsld\}}t|tjƒr|j}nt|tjƒr4|jj}d}|r`|rD| ¡n| ¡^}}}t|||ƒ}nt    |ƒ}|S)a*
    Construct an endpoint from a stream.
 
    :param trio.Stream stream:
    :param bool local: If true, return local endpoint. Otherwise return remote.
    :returns: An endpoint instance or ``repr()`` for streams that cannot be
        represented as an endpoint.
    :rtype: Endpoint or str
    r%T)
rrZ SocketStreamÚsocketZ    SSLStreamZtransport_streamÚ getsocknameÚ getpeernameÚEndpointÚrepr)rfr²rºÚis_sslÚaddrrIÚ_Zendpointrrr Ú_get_stream_endpoints
  rÂc@sPeZdZdZe ¡Zddddeedœdd„Z    e
dd„ƒZ e
dd    „ƒZ e
d
d „ƒZ e
d d „ƒZe
dd„ƒZe
dd„ƒZe
dd„ƒZe
dd„ƒZdEdd„Zdd„Zdd„ZdFdd„ZdGdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„ZdHd-d.„Zd/d0„Zd1d2„Z d3d4„Z!d5d6„Z"d7d8„Z#d9d:„Z$d;d<„Z%d=d>„Z&d?d@„Z'dAdB„Z(dCdD„Z)dS)Ir_z A WebSocket connection. NrUc    CsÊd|_t|jjƒ|_||_t ¡|_||_    d|_
g|_ ||_ d|_ |jr`t||||pVgd|_nd|_||_d|_d|_d|_d|_d|_t |¡\|_|_tƒ|_tƒ|_t ¡|_t ¡|_ d|_!dS)a–
        Constructor.
 
        Generally speaking, users are discouraged from directly instantiating a
        ``WebSocketConnection`` and should instead use one of the convenience
        functions in this module, e.g. ``open_websocket()`` or
        ``serve_websocket()``. This class has some tricky internal logic and
        timing that depends on whether it is an instance of a client connection
        or a server connection. The convenience functions handle this complexity
        for you.
 
        :param SocketStream stream:
        :param ws_connection wsproto.WSConnection:
        :param str host: The hostname to send in the HTTP request headers. Only
            used for client connections.
        :param str path: The URL path for this connection.
        :param list client_subprotocols: A list of desired subprotocols. Only
            used for client connections.
        :param list[tuple[bytes,bytes]] client_extra_headers: Extra headers to
            send with the connection request. Only used for client connections.
        :param int message_queue_size: The maximum number of messages that will be
            buffered in the library's internal message queue.
        :param int max_message_size: The maximum message size as measured by
            ``len()``. If a message is received that is larger than this size,
            then the connection is closed with code 1009 (Message Too Big).
        NrT)rHr¯r9r:r-)"Ú _close_reasonÚnextrÚ CONNECTION_IDÚ_idÚ_streamrZStrictFIFOLockÚ _stream_lockÚ_wsprotoÚ _message_sizeÚ_message_partsÚ_max_message_sizeÚ_reader_runningÚclientrÚ_initial_requestÚ_pathÚ _subprotocolÚ_handshake_headersÚ_reject_statusÚ_reject_headersÚ _reject_bodyZopen_memory_channelÚ _send_channelÚ _recv_channelrÚ_pingsr¤Ú_connection_proposalr¦rcÚ_close_handshakeÚ#_for_testing_peer_closed_connection)    r'rfZ ws_connectionrHrVrWrXr;r<rrr r(¬s:
þ
ÿ 
 
zWebSocketConnection.__init__cCs|jS)z™
        (Read-only) The reason why the connection was closed, or ``None`` if the
        connection is still open.
 
        :rtype: CloseReason
        )rÃr&rrr ÚclosedðszWebSocketConnection.closedcCs|jjS)z( (Read-only) Is this a client instance? ©rÉrÎr&rrr Ú    is_clientúszWebSocketConnection.is_clientcCs
|jj S)z( (Read-only) Is this a server instance? rÝr&rrr Ú    is_serverÿszWebSocketConnection.is_servercCst|jddS)zX
        The local endpoint of the connection.
 
        :rtype: Endpoint or str
        T©r²©rÂrÇr&rrr r²szWebSocketConnection.localcCst|jddS)zY
        The remote endpoint of the connection.
 
        :rtype: Endpoint or str
        Fràrár&rrr r³ szWebSocketConnection.remotecCs|jS)zº
        The requested URL path. For clients, this is set when the connection is
        instantiated. For servers, it is set after the handshake completes.
 
        :rtype: str
        )rÐr&rrr rVszWebSocketConnection.pathcCs|jS)zË
        (Read-only) The negotiated subprotocol, or ``None`` if there is no
        subprotocol.
 
        This is only valid after the opening handshake is complete.
 
        :rtype: str or None
        )rÑr&rrr rµ s
zWebSocketConnection.subprotocolcCs|jS)zÞ
        The HTTP headers that were sent by the remote during the handshake,
        stored as 2-tuples containing key/value pairs. Header keys are always
        lower case.
 
        :rtype: tuple[tuple[str,str]]
        )rÒr&rrr Úhandshake_headers,s    z%WebSocketConnection.handshake_headersr›c    Ãs(tƒ| ||¡IdHW5QRXdS)a7
        Close the WebSocket connection.
 
        This sends a closing frame and suspends until the connection is closed.
        After calling this method, any further I/O on this WebSocket (such as
        ``get_message()`` or ``send_message()``) will raise
        ``ConnectionClosed``.
 
        This method is idempotent: it may be called multiple times on the same
        connection without any errors.
 
        :param int code: A 4-digit code number indicating the type of closure.
        :param str reason: An optional string describing the closure.
        N)r"Ú_acloser¡rrr rF7szWebSocketConnection.aclosecÃs°|jr
dSzzv|jjtjkrBtddƒ|_| t||d¡IdHn|jjtj    tj
fkr`|j   ¡|j  ¡IdH|j  ¡IdHWntk
r–YnXW5| ¡IdHXdS)Nr›©r¢r)rÃÚ _close_streamrÉÚstater ÚOPENršÚ_sendrZ
CONNECTINGZ    REJECTINGrÚr¨r×rFrdrŠr¡rrr rãIs 
ÿ
 
zWebSocketConnection._aclosec    ÃsBz|j ¡IdH}Wn(tjtjfk
r<t|jƒd‚YnX|S)a£
        Receive the next WebSocket message.
 
        If no message is available immediately, then this function blocks until
        a message is ready.
 
        If the remote endpoint closes the connection, then the caller can still
        get messages sent prior to closing. Once all pending messages have been
        retrieved, additional calls to this method will raise
        ``ConnectionClosed``. If the local endpoint closes the connection, then
        pending messages are discarded and calls to this method will immediately
        raise ``ConnectionClosed``.
 
        :rtype: str or bytes
        :raises ConnectionClosed: if the connection is closed.
        N)r×ZreceiverÚClosedResourceErrorZ EndOfChannelrŠrÃ)r'Úmessagerrr Ú get_messagecs
zWebSocketConnection.get_messagecÃs~|jrt|jƒ‚||jkr*td|›dƒ‚|dkrDt dt d¡¡}t     ¡}||j|<| 
t |d¡IdH|  ¡IdHdS)aA
        Send WebSocket ping to remote endpoint and wait for a correspoding pong.
 
        Each in-flight ping must include a unique payload. This function sends
        the ping and then waits for a corresponding pong from the remote
        endpoint.
 
        *Note: If the remote endpoint recieves multiple pings, it is allowed to
        send a single pong. Therefore, the order of calls to ``ping()`` is
        tracked, and a pong will wake up its corresponding ping as well as all
        previous in-flight pings.*
 
        :param payload: The payload to send. If ``None`` then a random 32-bit
            payload is created.
        :type payload: bytes or None
        :raises ConnectionClosed: if connection is closed.
        :raises ValueError: if ``payload`` is identical to another in-flight
            ping.
        zPayload value z is already in flight.Nz!Ié ©Úpayload) rÃrŠrØrtÚstructÚpackÚrandomÚ getrandbitsrr¦rèrrd)r'rîr®rrr Úpingzs
 
 
zWebSocketConnection.pingcÃs*|jrt|jƒ‚| t|d¡IdHdS)zè
        Send an unsolicted pong.
 
        :param payload: The pong's payload. If ``None``, then no payload is
            sent.
        :type payload: bytes or None
        :raises ConnectionClosed: if connection is closed
        ríN)rÃrŠrèr)r'rîrrr Úpong™s    
zWebSocketConnection.pongcÃsX|jrt|jƒ‚t|tƒr&t|d}nt|tƒr<t|d}ntdƒ‚| |¡IdHdS)zÈ
        Send a WebSocket message.
 
        :param message: The message to send.
        :type message: str or bytes
        :raises ConnectionClosed: if connection is closed, or being closed
        ©Údatazmessage must be str or bytesN)    rÃrŠrrorÚbytesr rtrè)r'rêr®rrr Ú send_message¦s
 
 
 z WebSocketConnection.send_messagecCs|jr
dnd}|›d|j›S)z Connection ID and type. rÎr‡ú-)rÞrÆ)r'Útype_rrr Ú__str__¸szWebSocketConnection.__str__cÃs6||_|j|_| t|j|d¡IdH|j ¡dS)ah
        Accept the handshake.
 
        This method is only applicable to server-side connections.
 
        :param wsproto.events.Request request:
        :param subprotocol:
        :type subprotocol: str or None
        :param list[tuple[bytes,bytes]] extra_headers: A list of 2-tuples
            containing key/value pairs to send as HTTP headers.
        r´N)rÑr¯rÐrèr rcr¨)r'r|rµr:rrr r¶½s 
ÿzWebSocketConnection._acceptcÃsz|r | dtt|ƒƒ d¡f¡t||t|ƒd}| |¡IdH|r`t|d}| |¡IdHtddƒ|_    |j
  ¡dS)a¤
        Reject the handshake.
 
        :param int status_code: The 3 digit HTTP status code. In order to be
            RFC-compliant, this must not be 101, and should be an appropriate
            code in the range 300-599.
        :param list[tuple[bytes,bytes]] headers: A list of 2-tuples containing
            key/value pairs to send as HTTP headers.
        :param bytes body: An optional response body.
        zContent-lengthÚascii)r—r˜Úhas_bodyNrõiîzRejected WebSocket handshake) ÚappendroÚlenÚencoderÚboolrèrršrÃrÚr¨)r'r—r˜r™Z reject_connZ reject_bodyrrr r¸Ïs ÿ
 zWebSocketConnection._rejectcÃsXtjj}|jjtjkr*|j t|j    d¡|j
dkrD|  |¡IdHd|_ |j  ¡dS)zÿ
        If a stream is closed outside of this class, e.g. due to network
        conditions or because some other code closed our stream object, then we
        cannot perform the close handshake. We just need to clean up internal
        state.
        )r¢NF)rršZABNORMAL_CLOSURErÉrær rçÚsendrr1rÃÚ_close_web_socketrÍrÚr¨)r'Z close_reasonrrr Ú_abort_web_socketås
z%WebSocketConnection._abort_web_socketc    ÃsHd|_z&tƒ|j ¡IdHW5QRXWntjk
rBYnXdS)z Close the TCP connection. FN)rÍr"rÇrFrÚBrokenResourceErrorr&rrr råös z!WebSocketConnection._close_streamcÃs8t||ƒ|_t|jƒ}t d||¡|j ¡IdHdS)zÃ
        Mark the WebSocket as closed. Close the message channel so that if any
        tasks are suspended in get_message(), they will wake up with a
        ConnectionClosed exception.
        z%s websocket closed %rN)ršrÃrŠr]r^rÖrF)r'r¢rrrrr rs 
z%WebSocketConnection._close_web_socketcÃs:|jstdƒ‚|jdkr tdƒ‚|j ¡IdH}d|_|S)zÊ
        Return a proposal for a WebSocket handshake.
 
        This method can only be called on server connections and it may only be
        called one time.
 
        :rtype: WebSocketRequest
        z1This method is only valid for server connections.NzTNo proposal available. Did you call this method multiple times or at the wrong time?)rßÚ RuntimeErrorrÙrª)r'Úproposalrrr r{ s    
z WebSocketConnection._get_requestcÃst||ƒ}|j |¡dS)z¿
        Handle a connection request.
 
        This method is async even though it never awaits, because the event
        dispatch requires an async function.
 
        :param event:
        N)r«rÙr©)r'r®rrrr Ú_handle_request_events    
z)WebSocketConnection._handle_request_eventcÃs"|j|_t|jƒ|_|j ¡dS)zi
        Handle an AcceptConnection event.
 
        :param wsproto.eventsAcceptConnection event:
        N)rµrÑr°r:rÒrcr¨©r'r®rrr Ú_handle_accept_connection_event)s z3WebSocketConnection._handle_accept_connection_eventcÃs0|j|_t|jƒ|_|js,t|j|jdd‚dS)zI
        Handle a RejectConnection event.
 
        :param event:
        N©r™)r—rÓr°r˜rÔrýr–r    rrr Ú_handle_reject_connection_event3s  
ÿz3WebSocketConnection._handle_reject_connection_eventcÃs.|j|j7_|jr*t|j|j|jd‚dS)zC
        Handle a RejectData event.
 
        :param event:
        r N)rÕröZ body_finishedr–rÓrÔr    rrr Ú_handle_reject_data_event?s
 
ÿz-WebSocketConnection._handle_reject_data_eventcÃs’|jjtjkrVt|j|jpdƒ|_|jrB|j     ¡t
  d¡IdH|  |  ¡¡IdH| |j|jpfd¡IdH|j     ¡|jrŽ| ¡IdHdS)z]
        Handle a close event.
 
        :param wsproto.events.CloseConnection event:
        Nr)rÉrær ZREMOTE_CLOSINGršr¢rrÃrÛr¨rÚsleeprèÚresponserrÚrßrår    rrr Ú_handle_close_connection_eventJs
 
z2WebSocketConnection._handle_close_connection_eventc    Ãsè|jt|jƒ7_|j |j¡|j|jkr„d|j›d}d|_g|_td|ƒ|_| t    d|d¡IdH|j
  ¡IdHd|_ n`|j rät|tƒr˜dnd     |j¡}d|_g|_z|j |¡IdHWntjtjfk
râYnXdS)
        Handle a message event.
 
        :param event:
        :type event: wsproto.events.BytesMessage or wsproto.events.TextMessage
        zExceeded maximum message size: z bytesriñräNFr-rN)rÊrÿrörËrþrÌršrÃrèrr×rFrÍZmessage_finishedrr ÚjoinrÖrrrér)r'r®ÚerrÚmsgrrr Ú_handle_message_eventas(  ÿz)WebSocketConnection._handle_message_eventcÃs(t d||j¡| | ¡¡IdHdS)z¼
        Handle a PingReceived event.
 
        Wsproto queues a pong frame automatically, so this handler just needs to
        send it.
 
        :param wsproto.events.Ping event:
        z
%s ping %rN)r]r^rîrèrr    rrr Ú_handle_ping_events    z&WebSocketConnection._handle_ping_eventcÃs~t|jƒ}z|j|}Wntk
r.YdSX|jrz|j d¡\}}||krRdnd}t d|||¡| ¡||kr0qzq0dS)aÝ
        Handle a PongReceived event.
 
        When a pong is received, check if we have any ping requests waiting for
        this pong response. If the remote endpoint skipped any earlier pings,
        then we wake up those skipped pings, too.
 
        This function is async even though it never awaits, because the other
        event handlers are async, too, and event dispatch would be more
        complicated if some handlers were sync.
 
        :param event:
        Nrz  [skipped] ú z %s pong%s%r)r÷rîrØÚKeyErrorÚpopitemr]r^r¨)r'r®rîÚkeyÚskippedrrr Ú_handle_pong_event‹s
z&WebSocketConnection._handle_pong_eventcÃs$t|jt|jt|jt|jt|j    t
|j t |j t|jt|ji    }|jrrz| |j¡IdHWntk
rpd|_YnX|jr|j ¡D]v}t|ƒ}z(||}t d||¡||ƒIdHWq„tk
rÚt d||¡Yq„tk
rød|_YqüYq„Xq„z|j t¡IdH}Wn2tj tj!fk
rD| "¡IdHYqYnXt#|ƒdkr‚t d|¡|jj$t%j&kr| "¡IdHqt d|t#|ƒ¡|jj$t%j&krrz|j '|¡Wqrt(j)j*k
r}z:t d||¡|j+rò| |j+¡IdH| ,¡IdHW5d}~XYqrXqrt d    |¡dS)
zA A background task that reads network data and generates events. NFz%s received event: %sz$%s received unknown event type: "%s"rz*%s received zero bytes (connection closed)z%s received %d bytesz%s remote protocol error: %sz%s reader task finished)-r r
r rrrrrrrrr rr rrrrÏrèrŠrÍrÉÚeventsÚtyper]r^rÚwarningrÇZ receive_someÚ RECEIVE_BYTESrrrérrÿrær ZCLOSEDZ receive_dataÚwsprotoZ    utilitiesZRemoteProtocolErrorZ
event_hintrå)r'Úhandlersr®Z
event_typer…rörrrr rb¨s|÷  ÿÿ ÿ"z WebSocketConnection._reader_taskc
Ãs|j |¡}|j4IdHšft d|t|ƒ¡z|j |¡IdHWn6tj    tj
fk
rz|  ¡IdHt |j ƒd‚YnXW5QIdHRXdS)a
        Send an event to the remote WebSocket.
 
        The reader task and one or more writers might try to send messages at
        the same time, so this method uses an internal lock to serialize
        requests to send data.
 
        :param wsproto.events.Event event:
        Nz%s sending %d bytes)rÉrrÈr]r^rÿrÇZsend_allrrrérrŠrÃ)r'r®rörrr rèçs
zWebSocketConnection._send)r›N)N)N)N)*r4r5r6r7Ú    itertoolsÚcountrÅÚMESSAGE_QUEUE_SIZEÚMAX_MESSAGE_SIZEr(r£rÜrÞrßr²r³rVrµrârFrãrërórôrørûr¶r¸rrårr{rr
r r rrrrrbrèrrrr r_§s^ý D
    
 
 
 
 
    
 
 
 
 
 
 
 
 
   ?r_c@s,eZdZdZdd„Zedd„ƒZdd„ZdS)    r½z# Represents a connection endpoint. cCst|ƒ|_||_||_dSr)rÚaddressrIr¿)r'r&rIr¿rrr r(ýs
zEndpoint.__init__cCsx|jr
dnd}|jdkr|jr.|jdkr4|jr4d}ndt|jƒ}|jjdkrb|›d|j›|›S|›d    |j›d
|›S) zT Return a URL representation of a TCP endpoint, e.g.
        ``ws://127.0.0.1:80``. rlrkrRrSrNrTéz://z://[ú])r¿rIror&Úversion)r'rsZport_strrrr rhsÿÿ z Endpoint.urlcCsd|j›d|j›d|j›dS)z! Return endpoint info as string. zEndpoint(address="z", port=z    , is_ssl=ú))r&rIr¿r&rrr r“szEndpoint.__repr__N)r4r5r6r7r(r£rhr“rrrr r½ûs
 
r½c@sVeZdZdZdeeeedœdd„Zedd„ƒZ    edd    „ƒZ
e j d
œd d „Z d d„ZdS)rƒzé
    WebSocket server.
 
    The server class handles incoming connections on one or more ``Listener``
    objects. For each incoming connection, it creates a ``WebSocketConnection``
    instance and starts some background tasks,
    Nr€cCsBt|ƒdkrtdƒ‚||_||_||_||_||_||_||_dS)a 
        Constructor.
 
        Note that if ``host`` is ``None`` and ``port`` is zero, then you may get
        multiple listeners that have _different port numbers!_ See the
        ``listeners`` property.
 
        :param handler: the async function called with a :class:`WebSocketRequest`
            on each new connection.  The call will be made
            once the HTTP handshake completes, which notably implies that the
            connection's `path` property will be valid.
        :param listeners: The WebSocket will be served on each of the listeners.
        :param handler_nursery: An optional nursery to spawn connection tasks
            inside of. If ``None``, then a new nursery will be created
            internally.
        :param float connect_timeout: The number of seconds to wait for a client
            to finish connection handshake before timing out.
        :param float disconnect_timeout: The number of seconds to wait for a client
            to finish the closing handshake before timing out.
        rz)Listeners must contain at least one item.N)    rÿrtÚ_handlerÚ_handler_nurseryÚ
_listenersÚ_message_queue_sizerÌÚ_connect_timeoutÚ_disconnect_timeout)r'r…r†r~r;r<r=r>rrr r(!s zWebSocketServer.__init__cCsVt|jƒdkrtdƒ‚|jd}z|jWStk
rPtdt|ƒ›ƒd‚YnXdS)a§Returns the requested or kernel-assigned port number.
 
        In the case of kernel-assigned port (requested with port=0 in the
        constructor), the assigned port will be reflected after calling
        starting the `listen` task.  (Technically, once listen reaches the
        "started" state.)
 
        This property only works if you have a single listener, and that
        listener must be socket-based.
        rz>Cannot get port because this server has more than 1 listeners.rz"This socket does not have a port: N)rÿr-rr†rIÚAttributeErrorr¾)r'Úlistenerrrr rICs 
zWebSocketServer.portcCs~g}|jD]n}d\}}t|tjƒr*|j}nt|tjƒrB|jj}d}|rj| ¡}| t    |d|d|ƒ¡q
| t
|ƒ¡q
|S)a
        Return a list of listener metadata. Each TCP listener is represented as
        an ``Endpoint`` instance. Other listener types are represented by their
        ``repr()``.
 
        :returns: Listeners
        :rtype list[Endpoint or str]:
        r%Trr) r-rrZSocketListenerrºZ SSLListenerZtransport_listenerr»rþr½r¾)r'r†r2rºr¿Zsocknamerrr r†Xs
 
  zWebSocketServer.listenersrc
Ãs„t ¡4IdHšd}ttj|j|j|jd}| |¡IdHt     dd 
dd„|j Dƒ¡¡|  |¡t  ¡IdHW5QIdHRXdS)u¯
        Start serving incoming connections requests.
 
        This method supports the Trio nursery start protocol: ``server = await
        nursery.start(server.run, â€¦)``. It will block until the server is
        accepting connections and then return a :class:`WebSocketServer` object.
 
        :param task_status: Part of the Trio nursery start protocol.
        :returns: This method never returns unless cancelled.
        N)r~zListening on %sú,cSsg|] }t|ƒ‘qSr)ro)Ú.0Úlrrr Ú
<listcomp>‚sz'WebSocketServer.run.<locals>.<listcomp>)rrArÚserve_listenersÚ_handle_connectionr-r,Ústartr]r^rr†ÚstartedZ sleep_forever)r'rrer7rrr r„qs þÿ
zWebSocketServer.runcÃsât ¡4IdHšÂ}t|ttjƒ|j|jd}| |j    ¡t 
|j ¡}|  ¡IdH}W5QRX|j r|j ¡| ¡IdHW5QIdHR£dSz| |¡IdHW5t 
|j¡| ¡IdHW5QRXXW5QIdHRXdS)zÇ
        Handle an incoming connection by spawning a connection background task
        and a handler task inside a new nursery.
 
        :param stream:
        :type stream: trio.abc.Stream
        Nry)rrAr_r
r    rzr.rÌrarbZ move_on_afterr/r{Zcancelled_caughtZ cancel_scopeÚcancelrFr0r+)r'rfrerKZ connect_scoper|rrr r8†s"ý 
z"WebSocketServer._handle_connection)r4r5r6r7r$r%Ú CONN_TIMEOUTr(r£rIr†rÚTASK_STATUS_IGNOREDr„r8rrrr rƒsý "
 
rƒ)N)N)Pr)Ú collectionsrÚ
contextlibrÚ    functoolsrÚ    ipaddressrr"ÚloggingrñrYrïÚ urllib.parserpÚtypingrrrZtrio.abcZexceptiongrouprr r    r
Zwsproto.connectionr Zwsproto.frame_protocolZframe_protocolrZwsproto.eventsr r rrrrrrrZwsproto.utilitiesr°ÚmapÚintÚ __version__Úsplitr.r<r$r%rÚ    getLoggerr]r!r"rMrBrirjrgrxr}r=rˆÚ    ExceptionrErCrGrŠr–ršr¤r«rÂÚabcZ AsyncResourcer_r½rƒrrrr Ú<module>sª       , 
ý;þ @ý *þ $%þ (ÿ
ý 4,`X