Skip to content

Allow overriding SignalR's Redis backplane channel's prefix instead of relying on hub class' name #49457

@mstavrev

Description

@mstavrev

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

I am using SignalR infrastructure with Redis backplane. Since projects are part of the same solution, the most efficient way (code-wise) is to have the specific hub's class implementation shared between the various components. The problem is that this class has to contain certain implementation or reference(s) to other components within the solution, which aren't needed or can't be shared with all hub's using parties. That leads to the necessity to copy&paste the hub class' definition on multiple projects within the solution, under the same namespace. That leads to compile-time warnings as the (hub) class defined on one project overlaps with the (hub) class on another one.

Describe the solution you'd like

One way to deal with the problem is to modify this part:

_channels = new RedisChannels(typeof(THub).FullName!, _serverName);

Instead of always using the hub class' FullName to form the Redis prefix for the channel, to have a way to override it via options. This would allow different Hub classes (containing their specific implementation needs) to communicate without the need of class name overlapping.

Additional context

I'll try to be more precise about my actual issue. I need to use the hub to interface a front-end application (Angular based). Some activities that are started via the front-end (through a hub class that's part of an ASP Core web application) are completed on back-end instances. Those back-end instances must have a way to notify the caller or broadcast the result of the back-end handled operation to interested parties. Therefore I need two quite different hub class implementations - one to be integrated on the web infrastructure, which only knows how to trigger an operation and another one, for the back-end components that have very different dependency requirements to be able to push notifications to the hub-connected clients. I had already achieved it by using the same hub class name and suppressed the compile time CS0436 warnings, but that seems flimsy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-signalrIncludes: SignalR clients and servers

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions