Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add ability to send a message to a "user" #2401

Closed
davidfowl opened this Issue · 3 comments

3 participants

@davidfowl
Owner

This feature will give the user what we had prior to SignalR 1.0 (IConnectionIdGenerator) without risking security (allowing the user to change the connection id). We give the user a way to specify what the userId is based on an IRequest via IUserIdProvider:

public interface IUserIdProvider
{
    string GetUserId(IRequest request);
}

By default there will be an implementation that uses the user's IPrincipal.Identity.Name as the user name.

In hubs, you'll be able to send messages to these users via a new API:

public class MyHub : Hub
{
    public void Send(string userId, string message)
    {
        Clients.User(userId).send(message);
    }
}
@davidfowl davidfowl was assigned
@davidfowl davidfowl referenced this issue from a commit
@davidfowl davidfowl Added pluggable addressing of connections.
- Added ability to refer to a connection by a configurable user id.
- Added tests to verify this behavior.

#2401
9d0c0e9
@davidfowl davidfowl referenced this issue from a commit
@davidfowl davidfowl Added pluggable addressing of connections.
- Added ability to refer to a connection by a configurable user id.
- Added tests to verify this behavior.

#2401
2c9a40a
@davidfowl
Owner

Should we make it possible to identify a user by many ids (return IList)?

public interface IUserIdProvider
{
    IList<string> GetUserId(IRequest request);
}

Is it a realistic scenario to be able to address a connection by multiple user ids.

@gustavo-armenta

Tested feature doing the customer scenario where a website has basic authentication, there are many users authenticated, and a message is sent to one user who has multiple connections. Message is sent to the multiple connections of the user.

@DamianEdwards

This is nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.