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
# Azure Web PubSub service client library for Python - version 1.1.0b1
13
12
14
-
# Azure WebPubSubService client library for Python - version 1.0.0b2
15
13
14
+
[Azure Web PubSub Service](https://aka.ms/awps/doc) is an Azure-managed service that helps developers easily build web applications with real-time features and publish-subscribe pattern. Any scenario that requires real-time publish-subscribe messaging between server and clients or among clients can use Azure Web PubSub service. Traditional real-time features that often require polling from server or submitting HTTP requests can also use Azure Web PubSub service.
16
15
17
-
[Azure Web PubSub Service](https://aka.ms/awps/doc) is a service that enables you to build real-time messaging web applications using WebSockets and the publish-subscribe pattern. Any platform supporting WebSocket APIs can connect to the service easily, e.g. web pages, mobile applications, edge devices, etc. The service manages the WebSocket connections for you and allows up to 100K concurrent connections. It provides powerful APIs for you to manage these clients and deliver real-time messages.
16
+
You can use this library in your app server side to manage the WebSocket client connections, as shown in below diagram:
18
17
19
-
Any scenario that requires real-time publish-subscribe messaging between server and clients or among clients, can use Azure Web PubSub service. Traditional real-time features that often require polling from server or submitting HTTP requests, can also use Azure Web PubSub service.
20
-
21
-
We list some examples that are good to use Azure Web PubSub service:
22
-
23
-
-**High frequency data updates:** gaming, voting, polling, auction.
24
-
-**Live dashboards and monitoring:** company dashboard, financial market data, instant sales update, multi-player game leader board, and IoT monitoring.
25
-
-**Cross-platform live chat:** live chat room, chat bot, on-line customer support, real-time shopping assistant, messenger, in-game chat, and so on.
26
-
-**Real-time location on map:** logistic tracking, delivery status tracking, transportation status updates, GPS apps.
_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_
Use the returned token credential to authenticate the client:
81
+
A connection, also known as a client or a client connection, represents an individual WebSocket connection connected to the Web PubSub service. When successfully connected, a unique connection IDis assigned to this connection by the Web PubSub service.
A hub is a logical concept for a set of client connections. Usually you use one hub for one purpose, for example, a chat hub, or a notification hub. When a client connection is created, it connects to a hub, and during its lifetime, it belongs to that hub. Different applications can share one Azure Web PubSub service by using different hub names.
A group is a subset of connections to the hub. You can add a client connection to a group, or remove the client connection from the group, anytime you want. For example, when a client joins a chat room, or when a client leaves the chat room, this chat room can be considered to be a group. A client can join multiple groups, and a group can contain multiple clients.
Connections to Web PubSub can belong to one user. A user might have multiple connections, for example when a single user is connected across multiple devices or multiple browser tabs.
121
94
122
-
##Key concepts
95
+
### Message
123
96
124
-
### Connection
97
+
When the client is connected, it can send messages to the upstream application, or receive messages from the upstream application, through the WebSocket connection.
125
98
126
-
Connections, represented by a connection id, represent an individual websocket connection to the Web PubSub service. Connection id is always unique.
99
+
## Examples
127
100
128
-
### Hub
101
+
### Broadcast messages in JSON format
129
102
130
-
Hub is a logical concept for a set of connections. Connections are always connected to a specific hub. Messages that are broadcast to the hub are dispatched to all connections to that hub. Hub can be used for different applications, different applications can share one Azure Web PubSub service by using different hub names.
>>> service = WebPubSubServiceClient.from_connection_string('<connection_string>', hub='hub1')
107
+
>>> service.send_to_all(message= {
108
+
'from': 'user1',
109
+
'data': 'Hello world'
110
+
})
111
+
```
133
112
134
-
Group allow broadcast messages to a subset of connections to the hub. You can add and remove users and connections as needed. A client can join multiple groups, and a group can contain multiple clients.
113
+
The WebSocket client will receive JSON serialized text: `{"from": "user1", "data": "Hello world"}`.
135
114
136
-
### User
115
+
### Broadcast messages in plain-text format
137
116
138
-
Connections to Web PubSub can belong to one user. A user might have multiple connections, for example when a single user is connected across multiple devices or multiple browser tabs.
0 commit comments