2

The following code adds a user to a signalR group:

[Function("AddToGroup")]
public SignalROutputEntity AddUserToGroup(
    [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "addtogroup/{groupName}/{myId}")]
    HttpRequestData req,
    string groupName,
    string myId)
{
    var output = new SignalROutputEntity();
    output.Notifications.Add(new
    {
        userId = myId,
        groupName = groupName,
        action = "add"
    });
    output.Response = req.CreateResponse(HttpStatusCode.OK);
    return output;
}

public class SignalROutputEntity
{
    [SignalROutput(HubName = "myHub", ConnectionStringSetting = "AzureSignalRConnectionString")]
    public List<object> Notifications { get; set; } = new();

    public HttpResponseData? Response { get; set; }
}

I am aware that we can leverage signalR upstream to listen to and handle events when a user connects or disconnects to/from the signalR hub to increment or decrement a kind of counter. Aside from this method, is there a method or technique to query the Azure SignalR Service instance to determine the number of connected users per group?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.