dimanche 7 juin 2020

how can Use MapHub<> in runtime

please see this codes :

applicationBuilder.UseEndpoints(endpoints =>
{
    endpoints.MapControllers();
    //SignalR Hubs
    var typeFinder = GemEngineContext.Current.Resolve<ITypeFinder>();
    var assemblies = typeFinder.GetAssemblies();
    var hubAssembly = assemblies.First(d => d.FullName.StartsWith("MyProject.Hub"));

    var hubAssemblyHubs = hubAssembly.GetTypes()
                                     .Where(d => d.Name.EndsWithIgnoreCase("Hub"))
                                     .Select(d => d).ToList();

    foreach (var hubAssemblyHub in hubAssemblyHubs)
    {
        //endpoints.MapHub<GenericHub>("/someNameHub", options =>
        //{
        //    options.Transports = HttpTransportType.WebSockets;
        //});
    }
});

i get all hub types in hubAssemblyHubs variable.

endpoints.MapHub is a generic method and i have no idea how can use map from with HubType.

how can register all Hubs by HubTypes ?





Aucun commentaire:

Enregistrer un commentaire