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
U
[±d+ã@sŠdZddlmZddlmZmZddlmZmZm    Z    m
Z
m Z m Z ddl mZddlmZGdd    „d    eƒZed
d Gd d „d eƒƒZed
d Gdd„deƒƒZed
d Gdd„deƒƒZed
d Gdd„deƒƒZed
d Gdd„deƒƒZe deeƒZed
d Gdd„deeeƒƒZed
d Gdd„deeƒƒZed
d Gdd„deeƒƒZed
d Gdd„deƒƒZed
d Gdd „d eƒƒZd!S)"zc
wsproto/events
~~~~~~~~~~~~~~
 
Events that result from processing data on a WebSocket connection.
é)ÚABC)Ú    dataclassÚfield)ÚGenericÚListÚOptionalÚSequenceÚTypeVarÚUnioné)Ú    Extension)ÚHeadersc@seZdZdZdS)ÚEventz(
    Base class for wsproto events.
    N)Ú__name__Ú
__module__Ú __qualname__Ú__doc__©rrúEd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\wsproto/events.pyrsrT)Úfrozenc@sleZdZUdZeed<eed<eedZe    e
e e
efed<eedZ e ed<eedZeeed<dS)    ÚRequesta¿The beginning of a Websocket connection, the HTTP Upgrade request
 
    This event is fired when a SERVER connection receives a WebSocket
    handshake request (HTTP with upgrade header).
 
    Fields:
 
    .. attribute:: host
 
       (Required) The hostname, or host header value.
 
    .. attribute:: target
 
       (Required) The request target (path and query string)
 
    .. attribute:: extensions
 
       The proposed extensions.
 
    .. attribute:: extra_headers
 
       The additional request headers, excluding extensions, host, subprotocols,
       and version headers.
 
    .. attribute:: subprotocols
 
       A list of the subprotocols proposed in the request, as a list
       of strings.
    ÚhostÚtarget©Údefault_factoryÚ
extensionsÚ extra_headersÚ subprotocolsN)rrrrÚstrÚ__annotations__rÚlistrr
rr rr rrrrrrrs
ÿrc@sJeZdZUdZdZeeed<ee    dZ
e e ed<ee    dZ eed<dS)ÚAcceptConnectiona²The acceptance of a Websocket upgrade request.
 
    This event is fired when a CLIENT receives an acceptance response
    from a server. It is also used to accept an upgrade request when
    acting as a SERVER.
 
    Fields:
 
    .. attribute:: extra_headers
 
       Any additional (non websocket related) headers present in the
       acceptance response.
 
    .. attribute:: subprotocol
 
       The accepted subprotocol to use.
 
    NÚ subprotocolrrr)rrrrr"rrrrr rrr rr rrrrr!@s
r!c@s<eZdZUdZdZeed<eedZ    e
ed<dZ e ed<dS)    ÚRejectConnectiona´The rejection of a Websocket upgrade request, the HTTP response.
 
    The ``RejectConnection`` event sends the appropriate HTTP headers to
    communicate to the peer that the handshake has been rejected. You may also
    send an HTTP body by setting the ``has_body`` attribute to ``True`` and then
    sending one or more :class:`RejectData` events after this one. When sending
    a response body, the caller should set the ``Content-Length``,
    ``Content-Type``, and/or ``Transfer-Encoding`` headers as appropriate.
 
    When receiving a ``RejectConnection`` event, the ``has_body`` attribute will
    in almost all cases be ``True`` (even if the server set it to ``False``) and
    will be followed by at least one ``RejectData`` events, even though the data
    itself might be just ``b""``. (The only scenario in which the caller
    receives a ``RejectConnection`` with ``has_body == False`` is if the peer
    violates sends an informational status code (1xx) other than 101.)
 
    The ``has_body`` attribute should only be used when receiving the event. (It
    has ) is False the headers must include a
    content-length or transfer encoding.
 
    Fields:
 
    .. attribute:: headers (Headers)
 
       The headers to send with the response.
 
    .. attribute:: has_body
 
       This defaults to False, but set to True if there is a body. See
       also :class:`~RejectData`.
 
    .. attribute:: status_code
 
       The response status code.
 
    iÚ status_coderÚheadersFÚhas_bodyN) rrrrr$Úintrrr r%r r&Úboolrrrrr#Zs
% r#c@s&eZdZUdZeed<dZeed<dS)Ú
RejectDataaaThe rejection HTTP response body.
 
    The caller may send multiple ``RejectData`` events. The final event should
    have the ``body_finished`` attribute set to ``True``.
 
    Fields:
 
    .. attribute:: body_finished
 
       True if this is the final chunk of the body data.
 
    .. attribute:: data (bytes)
 
       (Required) The raw body data.
 
    ÚdataTÚ body_finishedN)rrrrÚbytesrr+r(rrrrr)†s
r)c@s8eZdZUdZeed<dZeeed<ddœdd„Z    dS)ÚCloseConnectiona™The end of a Websocket connection, represents a closure frame.
 
    **wsproto does not automatically send a response to a close event.** To
    comply with the RFC you MUST send a close event back to the remote WebSocket
    if you have not already sent one. The :meth:`response` method provides a
    suitable event for this purpose, and you should check if a response needs
    to be sent by checking :func:`wsproto.WSConnection.state`.
 
    Fields:
 
    .. attribute:: code
 
       (Required) The integer close code to indicate why the connection
       has closed.
 
    .. attribute:: reason
 
       Additional reasoning for why the connection has closed.
 
    ÚcodeNÚreason©ÚreturncCst|j|jdS)z?Generate an RFC-compliant close frame to send back to the peer.)r.r/)r-r.r/©ÚselfrrrÚresponse¸szCloseConnection.response)
rrrrr'rr/rrr4rrrrr-s
r-ÚTc@s2eZdZUdZeed<dZeed<dZeed<dS)ÚMessagea¾The websocket data message.
 
    Fields:
 
    .. attribute:: data
 
       (Required) The message data as byte string, can be decoded as UTF-8 for
       TEXT messages.  This only represents a single chunk of data and
       not a full WebSocket message.  You need to buffer and
       reassemble these chunks to get the full message.
 
    .. attribute:: frame_finished
 
       This has no semantic content, but is provided just in case some
       weird edge case user wants to be able to reconstruct the
       fragmentation pattern of the original stream.
 
    .. attribute:: message_finished
 
       True if this frame is the last one of this message, False if
       more frames are expected.
 
    r*TÚframe_finishedÚmessage_finishedN)    rrrrr5rr7r(r8rrrrr6Às
 r6c@seZdZUdZeed<dS)Ú TextMessagea9This event is fired when a data frame with TEXT payload is received.
 
    Fields:
 
    .. attribute:: data
 
       The message data as string, This only represents a single chunk
       of data and not a full WebSocket message.  You need to buffer
       and reassemble these chunks to get the full message.
 
    r*N)rrrrrrrrrrr9ßs
 r9c@seZdZUdZeed<dS)Ú BytesMessageavThis event is fired when a data frame with BINARY payload is
    received.
 
    Fields:
 
    .. attribute:: data
 
       The message data as byte string, can be decoded as UTF-8 for
       TEXT messages.  This only represents a single chunk of data and
       not a full WebSocket message.  You need to buffer and
       reassemble these chunks to get the full message.
    r*N)rrrrr,rrrrrr:ñs
r:c@s,eZdZUdZdZeed<ddœdd„ZdS)    ÚPinga«The Ping event can be sent to trigger a ping frame and is fired
    when a Ping is received.
 
    **wsproto does not automatically send a pong response to a ping event.** To
    comply with the RFC you MUST send a pong even as soon as is practical. The
    :meth:`response` method provides a suitable event for this purpose.
 
    Fields:
 
    .. attribute:: payload
 
       An optional payload to emit with the ping frame.
    óÚpayloadÚPongr0cCs t|jdS)z>Generate an RFC-compliant :class:`Pong` response to this ping.)r=)r>r=r2rrrr4sz Ping.responseN)rrrrr=r,rr4rrrrr;s
 r;c@seZdZUdZdZeed<dS)r>z˜The Pong event is fired when a Pong is received.
 
    Fields:
 
    .. attribute:: payload
 
       An optional payload to emit with the pong frame.
 
    r<r=N)rrrrr=r,rrrrrr>s
 
r>N)rÚabcrZ dataclassesrrÚtypingrrrrr    r
rr r rrr!r#r)r-r,rr5r6r9r:r;r>rrrrÚ<module>s6    (+