Skip to content

Commit 23e833f

Browse files
authored
Update signalr-concept-serverless-development-config.md
1 parent ce41dc1 commit 23e833f

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

articles/azure-signalr/signalr-concept-serverless-development-config.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,17 @@ The class-based model is dedicated for C#.
7676
The class-based model provides better programming experience, which can replace SignalR input and output bindings, with the following features:
7777
- More flexible negotiation, sending messages and managing groups experience.
7878
- More managing functionalities are supported, including closing connections, checking whether a connection, user, or group exists.
79-
- Strongly Typed hub
80-
- Unified connection string setting in one place.
79+
- Strongly typed hub
80+
- Unified hub name and connection string setting in one place.
8181

8282
The following code demonstrates how to write SignalR bindings in class-based model:
8383

84-
In the *Functions.cs* file, define your hub, which extends a base class `ServerlessHub`:
84+
Firstly, define your hub derived from a class `ServerlessHub`:
8585
```cs
8686
[SignalRConnection("AzureSignalRConnectionString")]
8787
public class Functions : ServerlessHub
8888
{
89-
private const string HubName = nameof(Functions);
89+
private const string HubName = nameof(Functions); // Used by SignalR trigger only
9090
9191
public Functions(IServiceProvider serviceProvider) : base(serviceProvider)
9292
{
@@ -126,7 +126,7 @@ var host = new HostBuilder()
126126

127127
### Negotiation experience in class-based model
128128

129-
Instead of using SignalR input binding `[SignalRConnectionInfoInput]`, negotiation in class-based model can be more flexible. Base class `ServerlessHub` has a method `NegotiateAsync`, which allows user to customize negotiation options such as `userId`, `claims`, etc.
129+
Instead of using SignalR input binding `[SignalRConnectionInfoInput]`, negotiation in class-based model can be more flexible. Base class `ServerlessHub` has a method `NegotiateAsync`, which allows users to customize negotiation options such as `userId`, `claims`, etc.
130130

131131
```cs
132132
Task<BinaryData> NegotiateAsync(NegotiationOptions? options = null)
@@ -141,7 +141,7 @@ You could send messages, manage groups, or manage clients by accessing the membe
141141
- `ServerlessHub.UserGroups` for managing users with groups, such as adding users to groups, removing users from groups.
142142
- `ServerlessHub.ClientManager` for checking connections existence, closing connections, etc.
143143

144-
### Strongly Typed Hub
144+
### Strongly typed Hub
145145

146146
[Strongly typed hub](/aspnet/core/signalr/hubs?#strongly-typed-hubs) allows you to use strongly typed methods when you send messages to clients. To use strongly typed hub in class based model, extract client methods into an interface `T`, and make your hub class derived from `ServerlessHub<T>`.
147147

@@ -158,7 +158,7 @@ Then you can use the strongly typed methods as follows:
158158
[SignalRConnection("AzureSignalRConnectionString")]
159159
public class Functions : ServerlessHub<IChatClient>
160160
{
161-
private const string HubName = nameof(Functions);
161+
private const string HubName = nameof(Functions); // Used by SignalR trigger only
162162
163163
public Functions(IServiceProvider serviceProvider) : base(serviceProvider)
164164
{
@@ -176,18 +176,18 @@ public class Functions : ServerlessHub<IChatClient>
176176
> [!NOTE]
177177
> You can get a complete project sample from [GitHub](https://github.com/aspnet/AzureSignalR-samples/tree/main/samples/DotnetIsolated-ClassBased/).
178178
179-
### Unified connection string setting in one place
179+
### Unified hub name and connection string setting in one place
180180

181-
You might have noticed the `SignalRConnection` attribute used on serverless hub classes. It looks like this:
182-
```cs
183-
[SignalRConnection("AzureSignalRConnectionString")]
184-
public class Functions : ServerlessHub<IChatClient>
185-
```
186-
187-
It allows you to customize where the SignalR Service bindings look for connection string. If it's absent, the default value `AzureSignalRConnectionString` is used.
181+
* The class name of the serverless hub is automatically used as `HubName`.
182+
* You might have noticed the `SignalRConnection` attribute used on serverless hub classes as follows:
183+
```cs
184+
[SignalRConnection("AzureSignalRConnectionString")]
185+
public class Functions : ServerlessHub<IChatClient>
186+
```
187+
It allows you to customize where the connection string for serverless hub is. If it's absent, the default value `AzureSignalRConnectionString` is used.
188188

189189
> [!IMPORTANT]
190-
> `SignalRConnection` attribute doesn't change the connection string setting of SignalR triggers, even though you use SignalR triggers inside the serverless hub. You should specify the connection string setting for each SignalR trigger if you want to customize it.
190+
> SignalR triggers and serverless hubs are independent. Therefore, the class name of serverless hub and `SignalRConnection` attribute doesn't change the setting of SignalR triggers, even though you use SignalR triggers inside the serverless hub.
191191

192192
# [In-process model](#tab/in-process)
193193

@@ -229,7 +229,7 @@ public class HubName1 : ServerlessHub
229229
}
230230
```
231231

232-
All functions that want to use the class-based model need to be a method of the class that inherits from **ServerlessHub**. The class name `SignalRTestHub` in the sample is the hub name.
232+
All functions that want to use the class-based model need to be a method of the class that inherits from **ServerlessHub**. The class name `HubName1` in the sample is the hub name.
233233

234234
### Define hub method
235235

@@ -250,13 +250,13 @@ In class based model, `[SignalRParameter]` is unnecessary because all the argume
250250

251251
### Negotiation experience in class-based model
252252

253-
Instead of using SignalR input binding `[SignalR]`, negotiation in class-based model can be more flexible. Base class `ServerlessHub` has a method.
253+
Instead of using SignalR input binding `[SignalR]`, negotiation in class-based model can be more flexible. Base class `ServerlessHub` has a method:
254254

255255
```cs
256256
SignalRConnectionInfo Negotiate(string userId = null, IList<Claim> claims = null, TimeSpan? lifeTime = null)
257257
```
258258

259-
This features user customizes `userId` or `claims` during the function execution.
259+
This feature allows user to customize `userId` or `claims` during the function execution.
260260

261261
## Use `SignalRFilterAttribute`
262262

0 commit comments

Comments
 (0)