@@ -13,8 +13,8 @@ Overview
1313The WebSocket API provides real-time status updates for batch user
1414creation operations.
1515
16- When a batch is processed asynchronously (i.e., the number of users
17- to generate or import meets or exceeds
16+ When a batch is processed asynchronously (i.e., the number of users to
17+ generate or import meets or exceeds
1818:ref: `OPENWISP_RADIUS_BATCH_ASYNC_THRESHOLD
1919<openwisp_radius_batch_async_threshold>`), the Django admin interface
2020automatically connects to the relevant endpoint to receive live status
@@ -28,7 +28,7 @@ All endpoints:
2828 after the connection is established.
2929
3030Authentication and Authorization
31- ---------------------------------
31+ --------------------------------
3232
3333All WebSocket endpoints require an authenticated user.
3434
@@ -57,10 +57,10 @@ If any check fails, the server closes the connection without sending any
5757message.
5858
5959Connection Endpoints
60- ---------------------
60+ --------------------
6161
62621. Batch User Creation Status
63- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6464
6565This endpoint delivers real-time status updates for a single batch user
6666creation operation.
@@ -88,9 +88,9 @@ A single batch user creation operation identified by its UUID.
8888Server-Pushed Messages
8989++++++++++++++++++++++
9090
91- After the connection is established, the client does not need to send
92- any messages. The server pushes exactly **one ** message when batch
93- processing finishes (either successfully or with an error).
91+ After the connection is established, the client does not need to send any
92+ messages. The server pushes exactly **one ** message when batch processing
93+ finishes (either successfully or with an error).
9494
9595Message type: ``batch_status_update ``
9696
@@ -105,19 +105,19 @@ The ``status`` field contains one of the following values:
105105.. list-table ::
106106 :header-rows: 1
107107
108- * - Value
108+ - - Value
109109 - Description
110- * - ``"pending" ``
110+ - - ``"pending" ``
111111 - The batch has been created but processing has not yet started.
112112 This value is not sent via WebSocket; it is visible only through
113113 the REST API or admin interface.
114- * - ``"processing" ``
115- - The batch is currently being processed. This value is not sent
116- via WebSocket; it is the status visible when the admin page is
117- opened and the WebSocket connection is established.
118- * - ``"completed" ``
114+ - - ``"processing" ``
115+ - The batch is currently being processed. This value is not sent via
116+ WebSocket; it is the status visible when the admin page is opened
117+ and the WebSocket connection is established.
118+ - - ``"completed" ``
119119 - Batch processing finished successfully. This is a terminal status.
120- * - ``"failed" ``
120+ - - ``"failed" ``
121121 - Batch processing encountered an error. This is a terminal status.
122122
123123.. note ::
@@ -130,16 +130,16 @@ Connection Lifecycle
130130++++++++++++++++++++
131131
1321321. The client connects to the endpoint with the batch UUID in the URL.
133- 2. If the user is authorized, the connection is accepted and the client
134- is added to the channel group ``radius_batch_<batch-id> ``.
133+ 2. If the user is authorized, the connection is accepted and the client is
134+ added to the channel group ``radius_batch_<batch-id> ``.
1351353. When batch processing finishes, the server sends one
136136 ``batch_status_update `` message containing the terminal status.
1371374. The client should close the connection upon receiving ``"completed" ``
138138 or ``"failed" ``.
1391395. On disconnect, the client is removed from the channel group.
140140
141141Example Client (JavaScript)
142- ++++++++++++++++++++++++++++
142+ +++++++++++++++++++++++++++
143143
144144Example based on the admin interface implementation:
145145
@@ -164,20 +164,20 @@ Example based on the admin interface implementation:
164164 Replace ``<batch-id> `` with the UUID of the batch object.
165165
166166Deployment Requirements
167- ------------------------
167+ -----------------------
168168
169169WebSocket support requires server-side configuration beyond the default
170170Django setup. The following components must be in place.
171171
172172ASGI Server
173173~~~~~~~~~~~
174174
175- Django's default WSGI server does not support WebSockets. You must use
176- an ASGI-compatible server such as `Daphne
175+ Django's default WSGI server does not support WebSockets. You must use an
176+ ASGI-compatible server such as `Daphne
177177<https://github.com/django/daphne> `_.
178178
179- Install Daphne and add it as the **first entry ** in ``INSTALLED_APPS ``
180- so that Django uses it as the ASGI server:
179+ Install Daphne and add it as the **first entry ** in ``INSTALLED_APPS `` so
180+ that Django uses it as the ASGI server:
181181
182182.. code-block :: python
183183
@@ -218,8 +218,8 @@ Install ``channels_redis`` and configure it:
218218 WebSocket Routing
219219~~~~~~~~~~~~~~~~~
220220
221- Import ``openwisp_radius.routing.websocket_urlpatterns `` and include it
222- in your project's ``URLRouter ``. Example ASGI routing module:
221+ Import ``openwisp_radius.routing.websocket_urlpatterns `` and include it in
222+ your project's ``URLRouter ``. Example ASGI routing module:
223223
224224.. code-block :: python
225225
0 commit comments