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: articles/azure-web-pubsub/tutorial-pub-sub-messages.md
+35-35Lines changed: 35 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,7 +98,7 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
98
98
* The package [Websocket.Client](https://github.com/Marfusios/websocket-client) is a third-party package supporting WebSocket connections. You can use any API/library that supports WebSocket.
99
99
* The SDK package `Azure.Messaging.WebPubSub` helps to generate the JWT token.
100
100
101
-
```console
101
+
```bash
102
102
mkdir subscriber
103
103
cd subscriber
104
104
dotnet new console
@@ -155,17 +155,17 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
155
155
156
156
After the connection is established, your client receives messages through the WebSocket connection. The client uses `client.MessageReceived.Subscribe(msg => ...));` to listen for incoming messages.
157
157
158
-
1. Run the following command replacing `<Web-PubSub-connection-string>` with the connection string you copied earlier:
158
+
1. To start the subscriber, run the following command replacing `<Web-PubSub-connection-string>` with the connection string you copied earlier:
159
159
160
-
```console
160
+
```bash
161
161
dotnet run <Web-PubSub-connection-string>"myHub1"
162
162
```
163
163
164
164
# [JavaScript](#tab/javascript)
165
165
166
166
1. First, create a project directory named `subscriber` and install required dependencies:
167
167
168
-
```console
168
+
```bash
169
169
mkdir subscriber
170
170
cd subscriber
171
171
npm init -y
@@ -198,9 +198,9 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
198
198
199
199
After the connection is established, your client receives messages through the WebSocket connection. The client uses `client.MessageReceived.Subscribe(msg => ...));` to listen for incoming messages.
200
200
201
-
1. Run the following command replacing `<Web-PubSub-connection-string>` with the connection string you copied earlier. If you are using Windows, you can use `set` instead of `export`.
201
+
1. Run the following command replacing `<Web-PubSub-connection-string>` with the connection string you copied earlier. If you are using Windowscommand shell, you can use `set` instead of `export`.
@@ -209,7 +209,7 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
209
209
210
210
1. First, create a project directory named `subscriber` and install required dependencies:
211
211
212
-
```console
212
+
```bash
213
213
mkdir subscriber
214
214
cd subscriber
215
215
# Create venv
@@ -263,9 +263,9 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
263
263
264
264
After the connection is established, your client will receive messages through the WebSocket connection. Use `await ws.recv()` to listen for incoming messages.
265
265
266
-
1. Run the following command replacing `<Web-PubSub-connection-string>` with the connection string you copied earlier:
266
+
1. Run the following command replacing `<Web-PubSub-connection-string>` with the connection string you copied earlier:
@@ -280,7 +280,7 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
280
280
281
281
1. Inside the `pubsub` directory, use Maven to create a new console app called `webpubsub-quickstart-subscriber`, then go to the *webpubsub-quickstart-subscriber* directory:
@@ -378,10 +378,10 @@ Clients connect to the Azure Web PubSub service through the standard WebSocket p
378
378
379
379
After connection is established, your client will receive messages through the WebSocket connection. Use `onMessage(String message)` to listen for incoming messages.
380
380
381
-
1. Navigate to the *webpubsub-quickstart-subscriber* directory and run the app with following command:
381
+
1. To start the subscriber app, go to the *webpubsub-quickstart-subscriber* directory and run the following command. Replace `<Web-PubSub-connection-string>` with the connection string you copied earlier.
@@ -394,7 +394,7 @@ Create a publisher using the Azure Web PubSub SDK to publish a message to the co
394
394
395
395
1. First, create a project directory named `publisher` and install required dependencies:
396
396
397
-
```console
397
+
```bash
398
398
mkdir publisher
399
399
cd publisher
400
400
dotnet new console
@@ -433,23 +433,23 @@ Create a publisher using the Azure Web PubSub SDK to publish a message to the co
433
433
434
434
The `SendToAllAsync()` call simply sends a message to all connected clients in the hub.
435
435
436
-
1. Send a message by running the command:
436
+
1. Send a message by running the following command. Replace `<Web-PubSub-connection-string>` with the connection string you copied earlier.
437
437
438
-
```console
439
-
dotnet run $connection_string "myHub1" "Hello World"
438
+
```bash
439
+
dotnet run <Web-PubSub-connection-string> "myHub1" "Hello World"
440
440
```
441
441
442
-
1. Check the command shell of the previous subscriber to see that it received the message:
442
+
1. Check the command shell of the subscriber to see that it received the message:
443
443
444
-
```text
444
+
```console
445
445
Message received: Hello World
446
446
```
447
447
448
448
# [JavaScript](#tab/javascript)
449
449
450
450
1. First, create a project directory named `publisher` and install required dependencies:
451
451
452
-
```console
452
+
```bash
453
453
mkdir publisher
454
454
cd publisher
455
455
npm init -y
@@ -471,14 +471,14 @@ Create a publisher using the Azure Web PubSub SDK to publish a message to the co
471
471
472
472
The `service.sendToAll()` call simply sends a message to all connected clients in a hub.
473
473
474
-
1. Send a message by running the command. If you are using Windows, you can use `set` instead of `export`.
474
+
1. To send a message, run the following command replacing `<Web-PubSub-connection-string>` with the connection string you copied earlier. If you are using Windows command shell, you can use `set` instead of `export`.
1. Check the previous command shell to that the subscriber received the message:
533
533
534
-
```text
534
+
```console
535
535
Received message: Hello World
536
536
```
537
537
538
538
# [Java](#tab/java)
539
539
540
540
1. Go to the `pubsub` directory. Use Maven to create a publisher console app `webpubsub-quickstart-publisher` and go to the *webpubsub-quickstart-publisher* directory:
@@ -588,15 +588,15 @@ Create a publisher using the Azure Web PubSub SDK to publish a message to the co
588
588
589
589
The `sendToAll()` call sends a message to all connected clients in a hub.
590
590
591
-
1. Go to the *webpubsub-quickstart-publisher* directory and run the project using the following command:
591
+
1. To send a message, go to the *webpubsub-quickstart-publisher* directory and run the project using the following command. Replace the `<Web-PubSub-connection-string>` with the connection string you copied earlier.
0 commit comments