Вопрос

I am curious as to how SignalR maps a request to the Hub?

How does it select which Hub to use? Where is the name of the hub in the request?

Additionally, how does it select which action in the hub gets to handle the request? Is that part of the request url?

And finally is there a way to tap into this pipeline (eg. an IActionFilter, IHubSelector, IActionSelector)?

Это было полезно?

Решение 2

It gets the types of the hubs via:

IAssemblyLocator, which returns the relevant assemblies.

SignalR than interrogates the assemblies for all types that passes:

private static bool IsHubType(Type type)
    {
      try
      {
        return typeof (IHub).IsAssignableFrom(type) && !type.IsAbstract 
                 && (type.Attributes.HasFlag((Enum) TypeAttributes.Public) 
                 || type.Attributes.HasFlag((Enum) TypeAttributes.NestedPublic));
      }
      catch
      {
        return false;
      }
    }

The types that pass the condition above are then used to create IHubDescriptors, whose type property are then resolved via the dependency resolver.

Другие советы

SignalR is open source. You can find most of what you are looking for here: https://github.com/SignalR/SignalR/tree/master/src/Microsoft.AspNet.SignalR.Core/Hubs

Start from this line for the incoming channel:

https://github.com/SignalR/SignalR/blob/master/src/Microsoft.AspNet.SignalR.Core/Hubs/HubDispatcher.cs#L145

Good luck!

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top