Skip to content

Commit c5c0916

Browse files
authored
Webpubsub client GA (#33294)
* rename on/off to subscribe/unsubscribe * expose start/stop * review * fix test * add doc * black * lint and changelog * review * review * Update CHANGELOG.md * update * update changelog * review * Update CHANGELOG.md * add sample * update doc * Update CHANGELOG.md
1 parent 1f88d67 commit c5c0916

File tree

14 files changed

+843
-157
lines changed

14 files changed

+843
-157
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# Release History
22

3+
## 1.0.0 (2024-01-31)
4+
5+
### Features Added
6+
7+
- Add Operation `open/close`
8+
9+
### Breaking Changes
10+
11+
- Rename operation `on` to `subscribe`
12+
- Rename operation `off` to `unsubscribe`
13+
- Remove model `DisconnectedError`
14+
- Rename model `OpenWebSocketError` to `OpenClientError`
15+
- Remove model `StartClientError`
16+
- Remove model `StartNotStoppedClientError`
17+
- Remove model `DisconnectedError`
18+
19+
### Other Changes
20+
21+
- Add docstring
22+
- First GA
23+
324
## 1.0.0b1 (2023-04-25)
425

526
- Initial version

sdk/webpubsub/azure-messaging-webpubsubclient/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Note that a client can only receive messages from groups that it has joined and
6060

6161
# Registers a listener for the event 'group-message' early before joining a group to not miss messages
6262
group_name = "group1";
63-
client.on("group-message", lambda e: print(f"Received message: {e.data}"));
63+
client.subscribe("group-message", lambda e: print(f"Received message: {e.data}"));
6464

6565
# A client needs to join the group it wishes to receive messages from
6666
client.join_group(groupName);
@@ -84,19 +84,19 @@ client.send_to_group(group_name, "hello world", "text");
8484
1. When a client is successfully connected to your Web PubSub resource, the `connected` event is triggered.
8585

8686
```python
87-
client.on("connected", lambda e: print(f"Connection {e.connection_id} is connected"))
87+
client.subscribe("connected", lambda e: print(f"Connection {e.connection_id} is connected"))
8888
```
8989

9090
2. When a client is disconnected and fails to recover the connection, the `disconnected` event is triggered.
9191

9292
```python
93-
client.on("disconnected", lambda e: print(f"Connection disconnected: {e.message}"))
93+
client.subscribe("disconnected", lambda e: print(f"Connection disconnected: {e.message}"))
9494
```
9595

96-
3. The `stopped` event will be triggered when the client is disconnected *and* the client stops trying to reconnect. This usually happens after the `client.stop()` is called, or `auto_reconnect` is disabled or a specified limit to trying to reconnect has reached. If you want to restart the client, you can call `client.start()` in the stopped event.
96+
3. The `stopped` event will be triggered when the client is disconnected *and* the client stops trying to reconnect. This usually happens after the `client.close()` is called, or `auto_reconnect` is disabled or a specified limit to trying to reconnect has reached. If you want to restart the client, you can call `client.open()` in the stopped event.
9797

9898
```python
99-
client.on("stopped", lambda : print("Client has stopped"))
99+
client.subscribe("stopped", lambda : print("Client has stopped"))
100100
```
101101

102102
---
@@ -106,10 +106,10 @@ A client can add callbacks to consume messages from your application server or g
106106

107107
```python
108108
# Registers a listener for the "server-message". The callback will be invoked when your application server sends message to the connectionID, to or broadcast to all connections.
109-
client.on("server-message", lambda e: print(f"Received message {e.data}"))
109+
client.subscribe("server-message", lambda e: print(f"Received message {e.data}"))
110110

111111
# Registers a listener for the "group-message". The callback will be invoked when the client receives a message from the groups it has joined.
112-
client.on("group-message", lambda e: print(f"Received message from {e.group}: {e.data}"))
112+
client.subscribe("group-message", lambda e: print(f"Received message from {e.group}: {e.data}"))
113113
```
114114

115115
---
@@ -125,7 +125,7 @@ However, you should be aware of `auto_rejoin_groups`'s limitations.
125125
client = WebPubSubClient("<client-access-url>", auto_rejoin_groups=True);
126126

127127
# Registers a listener to handle "rejoin-group-failed" event
128-
client.on("rejoin-group-failed", lambda e: print(f"Rejoin group {e.group} failed: {e.error}"))
128+
client.subscribe("rejoin-group-failed", lambda e: print(f"Rejoin group {e.group} failed: {e.error}"))
129129
```
130130

131131
---

0 commit comments

Comments
 (0)