Search code examples
javascriptsignalrazure-functionssignalr-hub

What is a SignalR Hub and how can it be renamed?


In my Azure Function I define a hubName but I can't seem to find any documentation what this actually is and how I can change it. If I change it from the default "chat" in my function it doesn't work anymore but where is it defined anyway?

{
  "disabled": false,
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    },
    {
      "type": "signalRConnectionInfo",
      "name": "connectionInfo",
      "userId": "{userId}",
      "hubName": ????,   <------------------------------------------
      "direction": "in"
    }
  ]
}

Solution

  • SignalR Hubs are a way to logically group connections as documented.

    Take an example of a chat application. A group of users could be part of the same hub which allows for sending messages between users in the group.

    The hubName here can be any string which is used to scope messages being sent between clients. All of your clients would have to connect to the same hub to be able to see messages being sent.