Debian Codegraph @

docs/reference/asyncio/server.rst

raw
1 Server (:mod:`asyncio`)
2 =======================
3
4 .. automodule:: websockets.asyncio.server
5
6 Creating a server
7 -----------------
8
9 .. autofunction:: serve
10
11 .. autofunction:: unix_serve
12
13 Routing connections
14 -------------------
15
16 .. automodule:: websockets.asyncio.router
17
18 .. autofunction:: route
19
20 .. autofunction:: unix_route
21
22 .. autoclass:: Router
23
24 .. currentmodule:: websockets.asyncio.server
25
26 Running a server
27 ----------------
28
29 .. autoclass:: Server
30
31 .. autoattribute:: connections
32
33 .. automethod:: close
34
35 .. automethod:: get_loop
36
37 .. automethod:: start_serving
38
39 .. automethod:: serve_forever
40
41 .. automethod:: is_serving
42
43 .. automethod:: wait_closed
44
45 .. autoattribute:: sockets
46
47 Using a connection
48 ------------------
49
50 .. autoclass:: ServerConnection
51
52 .. automethod:: respond
53
54 .. automethod:: __aiter__
55
56 .. automethod:: recv
57
58 .. automethod:: recv_streaming
59
60 .. automethod:: send
61
62 .. automethod:: close
63
64 .. automethod:: wait_closed
65
66 .. automethod:: ping
67
68 .. automethod:: pong
69
70 WebSocket connection objects also provide these attributes:
71
72 .. autoattribute:: id
73
74 .. autoattribute:: logger
75
76 .. autoproperty:: local_address
77
78 .. autoproperty:: remote_address
79
80 .. autoattribute:: latency
81
82 .. autoproperty:: state
83
84 The following attributes are available after the opening handshake,
85 once the WebSocket connection is open:
86
87 .. autoattribute:: request
88
89 .. autoattribute:: response
90
91 .. autoproperty:: subprotocol
92
93 The following attributes are available after the closing handshake,
94 once the WebSocket connection is closed:
95
96 .. autoproperty:: close_code
97
98 .. autoproperty:: close_reason
99
100 Broadcast
101 ---------
102
103 .. autofunction:: broadcast
104
105 HTTP Basic Authentication
106 -------------------------
107
108 websockets supports HTTP Basic Authentication according to
109 :rfc:`7235` and :rfc:`7617`.
110
111 .. autofunction:: basic_auth