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
| arg_name | The variable name of the argument in function to represent the input binding. |
167
+
| type | Must be `socketionegotiation`|
168
+
| hub | The hub name that a client needs to connect to. |
169
+
| connection | The name of the app setting that contains the Socket.IO connection string (defaults to `WebPubSubForSocketIOConnectionString`). |
170
+
| userId | The userId of the connection. It applys to all sockets in the connection. It becomes the `sub` claim in the generated token. |
171
+
172
+
---
173
+
147
174
## Trigger Binding
148
175
149
176
Azure Function uses trigger binding to trigger a function to process the events from the Web PubSub for Socket.IO.
@@ -213,8 +240,6 @@ The attribute for trigger binding is `[SocketIOTrigger]`.
213
240
214
241
`[SocketIOTrigger]` binds some variables to binding data. You can learn more about it from [Azure Functions binding expression patterns](../azure-functions/functions-bindings-expressions-patterns.md)
215
242
216
-
217
-
218
243
#### SocketIOAttribute
219
244
220
245
`SocketIOAttribute` is an alternative of `ParameterNames`, which simplify the function definition. For example, the following two definitions have the same effection:
| arg_name | The variable name of the argument in function to represent the trigger binding. |
426
+
| type | Must be `socketiotrigger`|
427
+
| hub | The hub name that a client needs to connect to. |
428
+
| data_type | Must be `DataType.STRING. |
429
+
| namespace | The namespace of the socket. Default: "/" |
430
+
| eventName | The event name that the function triggers for. Some event names are predefined: `connect` for socket connect event. `connected` for socket connected event. `disconnected` for socket disconnected event. And other events are defined by user and it need to match the event name sent by client side. |
431
+
432
+
---
433
+
434
+
### Request of Input Binding
435
+
436
+
The data structure of input binding arguments varies depending on the message type.
437
+
438
+
#### Connect
439
+
440
+
```json
441
+
{
442
+
"namespace": "",
443
+
"socketId": "",
444
+
"claims": {
445
+
"<claim-type>": [ "<claim-value>" ]
446
+
},
447
+
"query": {
448
+
"<query-key>": [ "<query-value>" ]
449
+
},
450
+
"headers":{
451
+
"<header-name>": [ "<header-value>" ]
452
+
},
453
+
"clientCertificates":{
454
+
{
455
+
"thumbprint": "",
456
+
"content": ""
457
+
}
458
+
}
459
+
}
460
+
```
461
+
462
+
| Property | Description |
463
+
|---------|---------|
464
+
| namespace | The namespace of the soceket. |
465
+
| socketId | The unique identity of the soceket. |
466
+
| claims | The claim of jwt of the client connection. Note, it's not the jwt when the service request the function, but the jwt when the Engine.IO client connects to the service. |
467
+
| query | The query of the client connection. Note, it's not the query when the service request the function, but the query when the Engine.IO client connects to the service. |
468
+
| headers | The headers of the client connection. Note, it's not the headers when the service request the function, but the headers when the Engine.IO client connects to the service. |
469
+
| clientCertificates | The client certificate if it's enabled |
470
+
471
+
#### Connected
472
+
473
+
```json
474
+
{
475
+
"namespace": "",
476
+
"socketId": "",
477
+
}
478
+
```
479
+
480
+
| Property | Description |
481
+
|---------|---------|
482
+
| namespace | The namespace of the soceket. |
483
+
| socketId | The unique identity of the soceket. |
484
+
485
+
#### Disconnected
486
+
487
+
```json
488
+
{
489
+
"namespace": "",
490
+
"socketId": "",
491
+
"reason": ""
492
+
}
493
+
```
494
+
495
+
| Property | Description |
496
+
|---------|---------|
497
+
| namespace | The namespace of the soceket. |
498
+
| socketId | The unique identity of the soceket. |
499
+
| reason | The connection close reason description. |
500
+
501
+
#### Normal events
502
+
503
+
```json
504
+
{
505
+
"namespace": "",
506
+
"socketId": "",
507
+
"payload": "",
508
+
"eventName": "",
509
+
"parameters": []
510
+
}
511
+
```
512
+
513
+
| Property | Description |
514
+
|---------|---------|
515
+
| namespace | The namespace of the soceket. |
516
+
| socketId | The unique identity of the soceket. |
517
+
| payload | The message payload in Engine.IO protocol |
518
+
| eventName | The event name of the request. |
519
+
| parameters | List of parameters of the message emittion. |
520
+
334
521
## Output Binding
335
522
336
523
The output binding currently support the following functionality:
@@ -406,6 +593,44 @@ app.generic('newMessage', {
406
593
407
594
---
408
595
596
+
# [Python Model v2](#tab/python-v2)
597
+
598
+
A function always needs a trigger binding. We use TimerTrigger as an example in codes.
599
+
600
+
```python
601
+
import azure.functions as func
602
+
from azure.functions.decorators.core import DataType
0 commit comments