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-signalr/signalr-quickstart-dotnet.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,11 +12,11 @@ ms.author: lianwei
12
12
13
13
# Quickstart: Create a chat room with ASP.NET and SignalR Service
14
14
15
-
Azure SignalR Service is based on [SignalR for ASP.NET Core 2.1](/aspnet/core/signalr/introduction?preserve-view=true&view=aspnetcore-2.1), which is **not** 100% compatible with ASP.NET SignalR. Azure SignalR Service re-implemented ASP.NET SignalR data protocol based on the latest ASP.NET Core technologies. When using Azure SignalR Service for ASP.NET SignalR, some ASP.NET SignalR features are no longer supported, for example, Azure SignalR does not replay messages when the client reconnects. Also, the Forever Frame transport and JSONP are not supported. Some code changes and proper version of dependent libraries are needed to make ASP.NET SignalR application work with SignalR Service.
15
+
Azure SignalR Service is based on [SignalR for ASP.NET Core 2.1](/aspnet/core/signalr/introduction?preserve-view=true&view=aspnetcore-2.1), which is **not** 100% compatible with ASP.NET SignalR. Azure SignalR Service reimplemented ASP.NET SignalR data protocol based on the latest ASP.NET Core technologies. When you use Azure SignalR Service for ASP.NET SignalR, some ASP.NET SignalR features are no longer supported, for example, Azure SignalR doesn't replay messages when the client reconnects. Also, the Forever Frame transport and JSONP aren't supported. Some code changes and proper version of dependent libraries are needed to make ASP.NET SignalR application work with SignalR Service.
16
16
17
17
Refer to the [version differences doc](/aspnet/core/signalr/version-differences?preserve-view=true&view=aspnetcore-3.1) for a complete list of feature comparison between ASP.NET SignalR and ASP.NET Core SignalR.
18
18
19
-
In this quickstart, you will learn how to get started with the ASP.NET and Azure SignalR Service for a similar [Chat Room application](./signalr-quickstart-dotnet-core.md).
19
+
In this quickstart, you learn how to get started with the ASP.NET and Azure SignalR Service for a similar [Chat Room application](./signalr-quickstart-dotnet-core.md).
*Serverless* mode is not supported for ASP.NET SignalR applications. Always use *Default* or *Classic* for the Azure SignalR Service instance.
40
+
*Serverless* mode isn't supported for ASP.NET SignalR applications. Always use *Default* or *Classic* for the Azure SignalR Service instance.
41
41
42
42
You can also create Azure resources used in this quickstart with [Create a SignalR Service script](scripts/signalr-cli-create-service.md).
43
43
@@ -108,7 +108,7 @@ Having issues? Try the [troubleshooting guide](signalr-howto-troubleshoot-guide.
108
108
> [!IMPORTANT]
109
109
> Deleting a resource group is irreversible and that the resource group and all the resources in it are permanently deleted. Make sure that you do not accidentally delete the wrong resource group or resources. If you created the resources for hosting this sample inside an existing resource group that contains resources you want to keep, you can delete each resource individually from their respective blades instead of deleting the resource group.
110
110
111
-
Sign in to the [Azure portal](https://portal.azure.com) and click **Resource groups**.
111
+
Sign in to the [Azure portal](https://portal.azure.com) and select **Resource groups**.
112
112
113
113
In the **Filter by name...** textbox, type the name of your resource group. The instructions for this quickstart used a resource group named *SignalRTestResources*. On your resource group in the result list, click **...** then **Delete resource group**.
Copy file name to clipboardExpand all lines: articles/azure-web-pubsub/tutorial-build-chat.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -63,7 +63,7 @@ Copy the fetched **ConnectionString** and it's used later in this tutorial as th
63
63
64
64
## Create the application
65
65
66
-
In Azure Web PubSub, there are two roles, server and client. This concept is similar to the server and client roles in a web application. Server is responsible for managing the clients, listen, and respond to client messages, while client's role is to send user's messages to server, and receive messages from server and visualize them to end user.
66
+
In Azure Web PubSub, there are two roles, server and client. This concept is similar to the server and client roles in a web application. Server is responsible to manage the clients, listen, and respond to client messages. Client is responsible to send and receive user's messages from server and visualize them for end user.
67
67
68
68
In this tutorial, we build a real-time chat web application. In a real web application, server's responsibility also includes authenticating clients and serving static web pages for the application UI.
69
69
@@ -351,7 +351,7 @@ We use the [Javalin](https://javalin.io/) web framework to host the web pages an
351
351
}
352
352
```
353
353
354
-
Depending on your setup, you might need to explicitly set the language level to Java 8. This can be donein the pom.xml. Add the following snippet:
354
+
Depending on your setup, you might need to explicitly set the language level to Java 8. This step can be donein the pom.xml. Add the following snippet:
In the above code, we simply print a message to console when a client is connected. You can see we use `req.context.userId` so we can see the identity of the connected client.
558
558
559
559
# [Java](#tab/java)
560
-
For now, you need to implement the event handler by your own in Java, the steps are straight forward following [the protocol spec](./reference-cloud-events.md) and illustrated below.
560
+
For now, you need to implement the event handler by your own in Java, the steps are straight forward following [the protocol spec](./reference-cloud-events.md) and illustrated in the below list:
561
561
562
562
1. Add HTTP handler for the event handler path, let's say `/eventhandler`.
563
563
@@ -665,7 +665,7 @@ Implement the `OnMessageReceivedAsync()` method in `Sample_ChatApp`.
665
665
}
666
666
```
667
667
668
-
This event handler uses `WebPubSubServiceClient.SendToAllAsync()` to broadcast the received message to all clients. You can see in the end we returned `UserEventResponse`, which contains a message directly to the caller and make the WebHook request success. If you have extra logic to validate and would like to break this call, you can throw an exception here. The middleware delivers the exception message to service and service drops current client connection. Don't forget to include the `using Microsoft.Azure.WebPubSub.Common;` statement at the beginning of the `Program.cs` file.
668
+
This event handler uses `WebPubSubServiceClient.SendToAllAsync()` to broadcast the received message to all clients. You can see in the end we returned `UserEventResponse`, which contains a message directly to the caller and make the WebHook request success. If you have extra logic to validate and would like to break this call, you can throw an exception here. The middleware delivers the exception message to service and service drops current client connection. Don't forget to include the `using Microsoft.Azure.WebPubSub.Common;` statement at the defining of the `Program.cs` file.
669
669
670
670
2. Update `index.html` to add the logic to send message from user to server and display received messages in the page.
671
671
@@ -730,7 +730,7 @@ The complete code sample of this tutorial can be found [here][code-csharp-net6],
730
730
731
731
This event handler uses `WebPubSubServiceClient.sendToAll()` to broadcast the received message to all clients.
732
732
733
-
You can see `handleUserEvent` also has a `res` object where you can send message back to the event sender. Here we simply call `res.success()` to make the WebHook return 200 (note this call is required even you don't want to return anything back to client, otherwise the WebHook never returns and client connection is closed).
733
+
You can see `handleUserEvent` also has a `res` object where you can send message back to the event sender. Here we simply call `res.success()` to make the WebHook return 200 (note this call is required even you don't want to return anything back to client, otherwise the WebHook never returns and client connection closes).
734
734
735
735
2. Update `index.html` to add the logic to send message from user to server and display received messages in the page.
Copy file name to clipboardExpand all lines: articles/azure-web-pubsub/tutorial-permission.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ ms.date: 11/01/2021
10
10
11
11
# Tutorial: Add authentication and permissions to your application when using Azure Web PubSub
12
12
13
-
In [Build a chat app](./tutorial-build-chat.md), you learned how to use WebSocket APIs to send and receive data with Azure Web PubSub. You might have noticed that, for simplicity, it doesn't require any authentication. Though Azure Web PubSub requires an access token to be connected, the `negotiate` API used in the tutorial to generate the access token doesn't need authentication. Anyone can call this API to get an access token.
13
+
In [Build a chat app](./tutorial-build-chat.md), you learned how to use WebSocket APIs to send and receive data with Azure Web PubSub. You notice that, for simplicity, it doesn't require any authentication. Though Azure Web PubSub requires an access token to be connected, the `negotiate` API used in the tutorial to generate the access token doesn't need authentication. Anyone can call this API to get an access token.
14
14
15
15
In a real-world application, you typically want the user to sign in first, before they can use your application. In this tutorial, you learn how to integrate Web PubSub with the authentication and authorization system of your application, to make it more secure.
16
16
@@ -40,7 +40,7 @@ First, add GitHub authentication to the chat room so the user can use a GitHub a
40
40
npm install --save passport-github2
41
41
```
42
42
43
-
1. Enable GitHub authentication by adding the following code to `server.js`:
43
+
1. Find the `server.js` file in your directory and enable GitHub authentication by adding the following code to `server.js`:
44
44
45
45
```javascript
46
46
const app = express();
@@ -81,7 +81,7 @@ First, add GitHub authentication to the chat room so the user can use a GitHub a
81
81
The preceding code uses [Passport.js](http://www.passportjs.org/) to enable GitHub authentication. Here's a simple illustration of how it works:
82
82
83
83
1. `/auth/github` redirects to github.com for sign-in.
84
-
1. After you sign in, GitHub redirects you to `/auth/github/callback` with a code for your application to complete the authentication. (To see how the profile returned from GitHub is verified and persisted in the server, see the verify callback in `passport.use()`.)
84
+
1. After you sign in, GitHub redirects you to `/auth/github/callback` with a code for your application to complete the authentication. (To see how the profile returned from GitHub is verified and persisted in the server, see the verified callback in `passport.use()`.)
85
85
1. After authentication is completed, you're redirected to the homepage (`/`) of the site.
86
86
87
87
For more details about GitHub OAuth and Passport.js, see the following articles:
@@ -142,11 +142,11 @@ First, add GitHub authentication to the chat room so the user can use a GitHub a
142
142
});
143
143
```
144
144
145
-
Now rerun the server, and you'll see a "not authorized" message for the first time you open the chat room. Select the sign-in link to sign in, and then you'll see it works as before.
145
+
Now rerun the server, and you see a "not authorized" message for the first time you open the chat room. Select the sign-in link to sign in, and then you see it works as before.
146
146
147
147
## Work with permissions
148
148
149
-
In the previous tutorials, you learned to use `WebSocket.send()` to directly publish messages to other clients by using subprotocol. In a real application, you might not want the client to be able to publish or subscribe to any group without permission control. In this section, you'll see how to control clients by using the permission system of Web PubSub.
149
+
In the previous tutorials, you learned to use `WebSocket.send()` to directly publish messages to other clients by using subprotocol. In a real application, you might not want the client to be able to publish or subscribe to any group without permission control. In this section, you see how to control clients by using the permission system of Web PubSub.
150
150
151
151
In Web PubSub, a client can perform the following types of operations with subprotocol:
152
152
@@ -161,7 +161,7 @@ Sending an event to the server is the default operation of the client. No protoc
161
161
162
162
For permission to join a group, the client still needs to join the group by using the "join group" message after it gets the permission. Alternatively, the server can use an API to add the client to a group, even if it doesn't have the join permission.
163
163
164
-
Now let's use this permission system to add a new feature to the chat room. You'll add a new type of user called *administrator* to the chat room. You'll allow the administrator to send system messages (messages that start with "[SYSTEM]") directly from the client.
164
+
Now let's use this permission system to add a new feature to the chat room. You add a new type of user called *administrator* to the chat room. You allow the administrator to send system messages (messages that start with "[SYSTEM]") directly from the client.
165
165
166
166
First, you need to separate system and user messages into two different groups so you can control their permissions separately.
Now run `node server <admin-id>`. You'll see that you can send a system message to every client when you sign in as `<admin-id>`.
267
+
Now run `node server <admin-id>`. You see that you can send a system message to every client when you sign in as `<admin-id>`.
268
268
269
-
But if you sign in as a different user, when you select**system message**, nothing happens. You might expect the service to give you an error to let you know the operation isn't allowed. To provide this feedback, you can set `ackId` when you're publishing the message. Whenever `ackId` is specified, Web PubSub will return a message with a matching `ackId` to indicate whether the operation has succeeded or not.
269
+
But if you sign in as a different user, when you select **system message**, nothing happens. You might expect the service to give you an error to let you know the operation isn't allowed. To provide this feedback, you can set`ackId` when you're publishing the message. Whenever `ackId` is specified, Web PubSub returns a message with a matching `ackId` to indicate whether the operation has succeeded or not.
270
270
271
271
Change the code of sending a system message to the following code:
272
272
@@ -297,7 +297,7 @@ ws.onmessage = event => {
297
297
};
298
298
```
299
299
300
-
Now rerun the server, and sign in as a different user. You'll see an error message when you're trying to send a system message.
300
+
Now rerun the server, and sign in as a different user. You see an error message when you're trying to send a system message.
301
301
302
302
The complete code sample of this tutorial can be found on [GitHub][code].
0 commit comments