There are several ways to get the connection ID:
- For the client connection itself, when using the subprotocol, the client receives a
connected
message once it is connected, which contains the connection Id: https://learn.microsoft.com/azure/azure-web-pubsub/reference-json-webpubsub-subprotocol#connected - For the upstream server side, when the events are triggered, it contains the
connectionId
in the request header asce-connectionId
, a sample usage about register upstream event handlers and fetch headers using sharp is here: https://learn.microsoft.com/en-us/azure/azure-web-pubsub/tutorial-build-chat?tabs=csharp
Could you elaborate more about your scenario when you want to SendToConnectionAsync
?