You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+27-10Lines changed: 27 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,20 @@
1
1
# Realtime Pub/Sub Client for Python
2
2
3
-
The `realtime-pubsub-client-python` is a Python client library for interacting with [Realtime Pub/Sub](https://realtime.21no.de) applications. It enables developers to manage real-time WebSocket connections, handle subscriptions, and process messages efficiently. The library provides a simple and flexible API to interact with realtime applications, supporting features like publishing/sending messages, subscribing to topics, handling acknowledgements, and waiting for replies with timeout support.
3
+
The `realtime-pubsub-client-python` is a Python client library for interacting
4
+
with [Realtime Pub/Sub](https://realtime.21no.de) applications. It enables developers to manage real-time WebSocket
5
+
connections, handle subscriptions, and process messages efficiently. The library provides a simple and flexible API to
6
+
interact with realtime applications, supporting features like publishing/sending messages, subscribing to topics,
7
+
handling acknowledgements, and waiting for replies with timeout support.
4
8
5
9
## Features
6
10
7
-
-**WebSocket Connection Management**: Seamlessly connect and disconnect from the Realtime Pub/Sub service with automatic reconnection support.
11
+
-**WebSocket Connection Management**: Seamlessly connect and disconnect from the Realtime Pub/Sub service with
12
+
automatic reconnection support.
8
13
-**Topic Subscription**: Subscribe and unsubscribe to topics for receiving messages.
9
-
-**Topic Publishing**: [Publish](https://realtime.21no.de/documentation/#publishers) messages to specific topics with optional message types and compression.
10
-
-**Message Sending**: [Send](https://realtime.21no.de/documentation/#websocket-inbound-messaging) messages to backend applications with optional message types and compression.
14
+
-**Topic Publishing**: [Publish](https://realtime.21no.de/documentation/#publishers) messages to specific topics with
15
+
optional message types and compression.
16
+
-**Message Sending**: [Send](https://realtime.21no.de/documentation/#websocket-inbound-messaging) messages to backend
17
+
applications with optional message types and compression.
11
18
-**Event Handling**: Handle incoming messages with custom event listeners.
12
19
-**Acknowledgements and Replies**: Wait for gateway acknowledgements or replies to messages with timeout support.
13
20
-**Error Handling**: Robust error handling and logging capabilities.
@@ -37,6 +44,7 @@ from realtime_pubsub_client import RealtimeClient
37
44
38
45
APP_ID='your-app-id'
39
46
47
+
40
48
asyncdefmain():
41
49
asyncdefget_url():
42
50
# replace with your access token retrieval strategy
@@ -157,9 +168,11 @@ Handle errors and disconnections:
157
168
defon_error(error):
158
169
print('WebSocket error:', error)
159
170
171
+
160
172
defon_close(event):
161
173
print('WebSocket closed:', event)
162
174
175
+
163
176
client.on('error', on_error)
164
177
client.on('close', on_close)
165
178
```
@@ -192,13 +205,15 @@ Creates a new `RealtimeClient` instance.
192
205
await client.disconnect()
193
206
```
194
207
195
-
-**`subscribe_remote_topic(topic)`**: [Subscribes](https://realtime.21no.de/documentation/#subscribers) the connection to a remote topic.
208
+
-**`subscribe_remote_topic(topic)`**: [Subscribes](https://realtime.21no.de/documentation/#subscribers) the connection
209
+
to a remote topic.
196
210
197
211
```python
198
212
await client.subscribe_remote_topic(topic)
199
213
```
200
214
201
-
-**`unsubscribe_remote_topic(topic)`**: [Unsubscribes](https://realtime.21no.de/documentation/#subscribers) the connection from a remote topic.
215
+
-**`unsubscribe_remote_topic(topic)`**: [Unsubscribes](https://realtime.21no.de/documentation/#subscribers) the
216
+
connection from a remote topic.
202
217
203
218
```python
204
219
await client.unsubscribe_remote_topic(topic)
@@ -260,17 +275,19 @@ This library is licensed under the MIT License.
260
275
261
276
---
262
277
263
-
For more detailed examples and advanced configurations, please refer to the [documentation](https://realtime.21no.de/docs).
278
+
For more detailed examples and advanced configurations, please refer to
279
+
the [documentation](https://realtime.21no.de/docs).
264
280
265
281
## Notes
266
282
267
283
- Ensure that you have an account and an app set up with [Realtime Pub/Sub](https://realtime.21no.de).
268
-
- Customize the `urlProvider` or URL to retrieve the access token for connecting to your realtime application.
284
+
- Customize the `url_provider` or URL to retrieve the access token for connecting to your realtime application.
269
285
- Implement the `get_auth_token` function according to your authentication mechanism.
270
286
- Optionally use the `logger` option to integrate with your application's logging system.
271
287
- Handle errors and disconnections gracefully to improve the robustness of your application.
272
288
- Make sure to handle timeouts when waiting for replies to avoid hanging operations.
273
289
274
290
---
275
291
276
-
Feel free to contribute to this project by submitting issues or pull requests on [GitHub](https://github.com/BackendStack21/realtime-pubsub-client-python).
292
+
Feel free to contribute to this project by submitting issues or pull requests
293
+
on [GitHub](https://github.com/BackendStack21/realtime-pubsub-client-python).
0 commit comments