1

The following code successfully receives "connected" events from signalR upstream when a user connects, proving that the configuration in .NET 6.0 and dotnet-isolated mode are correct:


    [Function("OnConnected")]
    [SignalROutput(HubName = HubName)]
    public async Task<MyMessage> OnConnectedAsync([SignalRTrigger(HubName, "connections", "connected")] SignalRInvocationContext invocationContext)
    {
        _logger?.LogInformation("Connection established: {@InvocationContext}", invocationContext);
        string someMessage = await DoSomethingAsync();
        return new MyMessage
        {
            Arguments = new[]
            {
                new
                {
                 message = someMessage
                }
            },
            Target = "onConnected"
        };
    }

The client code has been subscribed after the successful negotiation to the signalR hub listening to receiving "onConnected" event per the following code:


        connection.On("onConnected", (Action<object>)(message =>
        {
            var packet = Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(message.ToString());
        }));

connection is a HubConnection object type in the code snippet above.

The problem is that when the upstream serverless function is called the client code above does not recieve "onConnected" event and it won't execute.

I expected to receieve the "onConnected" event in the client side code. Also, how can I send a message to a group of users?

Arash
  • 3,628
  • 5
  • 46
  • 70

0 Answers0