Server to client call not working outside context.

Issue #8 resolved
Christopher Hall created an issue

Using code such as the following fails to call the client.

GlobalHost.ConnectionManager.GetHubContext<HubType>().Clients.Client(connectionId).Test("hello");

This appears to be because the global dependency resolver is not set

GlobalHost.DependencyResolver = dependencyResolver;

Setting that is only half the answer though. I'm not sure what object to use for that global dependency resolver as the AutofacDependencyResolver takes an ILifetimeScope and I'm not sure what to use for that.

Further, this gets worse under multi tenancy as the resolver only appears to work for its own tenant.

Comments (2)

  1. Christopher Hall reporter

    As seems to be all too often the case this was more to do with my lack of understanding than anything else.

    I have resolved my issue relating to calling from a tenant to a client by using code similar to the following on the server.

    var hc = resolver.Resolve<IConnectionManager>().GetHubContext<MyHub>();
    hc.Clients.Client(_connections[tenantName]).Test(tenantName);
    

    As long as an AutofacDependencyResolver resolver is injected from the appropriate tenant this appears to work.

    I don't have any need to send messages across tenants. At the moment I can't see how that would be done as the resolver does appear to be tenant specific.

  2. Log in to comment