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
@@ -30,14 +30,13 @@ Get started with the Azure Web PubSub client SDK for Python or JavaScript to cre
30
30
## Prerequisites
31
31
32
32
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
33
-
- A Web PubSub instance. If you haven't created one, you can follow the guidance: [Create a Web PubSub instance from Azure portal](./howto-develop-create-instance.md)
34
33
- A file editor such as Visual Studio Code.
35
34
36
35
## Setting up
37
36
38
37
### Create an Azure Web PubSub service instance
39
38
40
-
1. In the Azure portal and from **Home**, select **Create a resource**.
39
+
1. In the Azure portal **Home** page, select **Create a resource**.
41
40
1. In the **Search the Marketplace** box, enter *Web PubSub*.
42
41
1. Select **Web PubSub** from the results.
43
42
1. Select **Create**.
@@ -47,7 +46,7 @@ Get started with the Azure Web PubSub client SDK for Python or JavaScript to cre
47
46
1. Enter a **Resource Name** for the service instance.
48
47
1. Select **Pricing tier**. You can choose **Free** for testing.
49
48
1. Select **Create**, then **Create** again to confirm the new service instance.
50
-
1.Select **Go to resource** to go to the service instance when the deployment is complete.
49
+
1.Once deployment is complete, select **Go to resource**.
51
50
52
51
### Generate the client URL
53
52
@@ -88,31 +87,44 @@ Install both the .NET Core SDK and dotnet runtime.
88
87
89
88
### Install the package
90
89
90
+
Install the Azure Web PubSub client SDK for the language you're using.
91
+
91
92
# [JavaScript](#tab/javascript)
92
93
93
-
The SDK is available as an [npm module](https://www.npmjs.com/package/@azure/web-pubsub-client)
94
+
The SDK is available as an [npm module](https://www.npmjs.com/package/@azure/web-pubsub-client).
95
+
96
+
OPen a terminal winder and install the Web PubSub client SDK using the following command.
94
97
95
98
```bash
96
99
npm install @azure/web-pubsub-client
97
100
```
98
101
102
+
Note that the SDK is available as an [npm module](https://www.npmjs.com/package/@azure/web-pubsub-client).
103
+
99
104
# [C#](#tab/csharp)
100
105
101
-
The SDK is available as an [NuGet packet](https://www.nuget.org/packages/Azure.Messaging.WebPubSub.Client)
106
+
Open a terminal window to create your project and install the Web PubSub client SDK.
Note that the The SDK is available as a [NuGet packet](https://www.nuget.org/packages/Azure.Messaging.WebPubSub.Client).
123
+
111
124
---
112
125
113
126
## Code examples
114
127
115
-
From your terminal window, create a new directory and navigate to it.
116
128
117
129
### Create and connect to the Web PubSub service
118
130
@@ -122,6 +134,13 @@ For this example, you can use the Client Access URL you generated in the portal.
122
134
123
135
# [JavaScript](#tab/javascript)
124
136
137
+
In the terminal window, create a new directory for your project and change to that directory.
138
+
139
+
```bash
140
+
mkdir webpubsub-client
141
+
cd webpubsub-client
142
+
```
143
+
125
144
Create a file with name `index.js` and enter following code:
126
145
127
146
```javascript
@@ -145,13 +164,13 @@ var client = new WebPubSubClient(new Uri(clientURL));
145
164
146
165
---
147
166
148
-
## Subscribe to a group
167
+
###Subscribe to a group
149
168
150
169
To receive message from a group, you need to subscribe to the group and add a callback to handle messages you receive from the group. The following code subscribes the client to a group called `group1`.
151
170
152
171
# [JavaScript](#tab/javascript)
153
172
154
-
Add this code to the `index.js` file:
173
+
Add this following code to the `index.js` file:
155
174
156
175
```javascript
157
176
// callback to group messages.
@@ -168,7 +187,7 @@ client.joinGroup("group1");
168
187
169
188
# [C#](#tab/csharp)
170
189
171
-
Add this code to the `Program.cs` file:
190
+
Add the following code to the `Program.cs` file:
172
191
173
192
```csharp
174
193
// callback to group messages.
@@ -184,23 +203,24 @@ await client.StartAsync();
184
203
// join a group to subscribe message from the group
185
204
awaitclient.JoinGroupAsync("group1");
186
205
```
206
+
187
207
---
188
208
189
-
## Publish a message to a group
209
+
###Publish a message to a group
190
210
191
-
Then you can send messages to the group and as the client has joined the group before, you can receive the message you've sent.
211
+
After your client has subscribed to the group, it can send messages to and receive the message from the group.
@@ -210,11 +230,11 @@ await client.SendToGroupAsync("group1", BinaryData.FromString("Hello World"), We
210
230
211
231
## Run the code
212
232
213
-
Run the client in your terminal. To verify the client is sending and receiving messages, you can open a second terminal and start the client from the same directory. You see the message you sent in the first terminal window.
233
+
Run the client in your terminal. To verify the client is sending and receiving messages, you can open a second terminal and start the client from the same directory. You can see the message you sent from the second client in the first client's terminal window.
214
234
215
235
# [JavaScript](#tab/javascript)
216
236
217
-
Add this code to the `index.js` file:
237
+
To start the client go the terminal and run the following command. Replace the `<Client Access URL>` with the Client Access URL you copied from the portal.
218
238
219
239
```bash
220
240
export WebPubSubClientURL="<Client Access URL>"
@@ -223,7 +243,7 @@ node index.js
223
243
224
244
# [C#](#tab/csharp)
225
245
226
-
Copy the Client Access URL from the portal and run the following command in your terminal replacing the `<client-access-url>` with the Client Access URL you copied from the portal:
246
+
To start the client, run the following command in your terminal replacing the `<client-access-url>` with the Client Access URL you copied from the portal:
227
247
228
248
```bash
229
249
dotnet run <client-access-url>
@@ -237,9 +257,7 @@ To delete the resources you created in this quickstart, you can delete the resou
237
257
238
258
## Next steps
239
259
240
-
This quickstart provides you with a basic idea of how to connect to the Web PubSub with client SDK and how to subscribe to group messages and publish messages to groups.
241
-
242
-
To learn more the Web PubSub service SDKs, see the following resources:
260
+
To learn more the Web PubSub service client SDKs, see the following resources:
0 commit comments