Skip to content

Commit ba2ffae

Browse files
authored
minor improve description.
1 parent e772264 commit ba2ffae

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

articles/azure-web-pubsub/reference-functions-bindings.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,11 @@ Use the function trigger to handle requests from Azure Web PubSub service.
7979
```cs
8080
[FunctionName("WebPubSubTrigger")]
8181
public static void Run(
82-
[WebPubSubTrigger("<hub>", WebPubSubEventType.User, "message")]
83-
UserEventRequest request,
84-
WebPubSubConnectionContext context,
85-
string data,
86-
WebPubSubDataType dataType)
82+
[WebPubSubTrigger("<hub>", WebPubSubEventType.User, "message")] UserEventRequest request)
8783
{
88-
Console.WriteLine($"Request from: {context.UserId}");
89-
Console.WriteLine($"Request message data: {data}");
90-
Console.WriteLine($"Request message dataType: {dataType}");
84+
Console.WriteLine($"Request from: {request.ConnectionContext.UserId}");
85+
Console.WriteLine($"Request message data: {request.Data}");
86+
Console.WriteLine($"Request message dataType: {request.DataType}");
9187
}
9288
```
9389
@@ -155,7 +151,7 @@ Here's an `WebPubSubTrigger` attribute in a method signature:
155151
```csharp
156152
[FunctionName("WebPubSubTrigger")]
157153
public static void Run([WebPubSubTrigger("<hub>", <WebPubSubEventType>, "<event-name>")]
158-
WebPubSubConnectionContext context, ILogger log)
154+
WebPubSubConnectionContext context, ILogger log)
159155
{
160156
...
161157
}
@@ -195,6 +191,9 @@ In weakly typed language like JavaScript, `name` in `function.json` will be used
195191
|clientCertificates|`IList<ClientCertificate>`|A list of certificate thumbprint from clients in system `connect` request|-|
196192
|reason|`string`|Reason in system `disconnected` request|-|
197193

194+
> [!IMPORTANT]
195+
> In C#, mutliple types supported parameter __MUST__ be put in the first, i.e. `request` or `data` that other than the default `BinaryData` type to make the function binding correctly.
196+
198197
### Return response
199198

200199
`WebPubSubTrigger` will respect customer returned response for synchronous events of `connect` and user event. Only matched response will be sent back to service, otherwise, it will be ignored. Besides, `WebPubSubTrigger` return object supports users to `SetState()` and `ClearStates()` to manage the metadata for the connection. And the extension will merge the results from return value with the original ones from request `WebPubSubConnectionContext.States`. Value in existing key will be overwrite and value in new key will be added.

0 commit comments

Comments
 (0)