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

Closed
davidfowl opened this Issue Aug 7, 2013 · 3 comments

Comments

Projects
None yet
3 participants
Owner

davidfowl commented Aug 7, 2013

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);
    }
}

@ghost ghost assigned davidfowl Aug 7, 2013

davidfowl added a commit that referenced this issue Aug 7, 2013

Added pluggable addressing of connections.
- Added ability to refer to a connection by a configurable user id.
- Added tests to verify this behavior.

#2401

davidfowl added a commit that referenced this issue Aug 7, 2013

Added pluggable addressing of connections.
- Added ability to refer to a connection by a configurable user id.
- Added tests to verify this behavior.

#2401

@ghost ghost assigned gustavo-armenta Aug 7, 2013

Owner

davidfowl commented Aug 8, 2013

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.

Contributor

gustavo-armenta commented Aug 15, 2013

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.

Owner

DamianEdwards commented Aug 16, 2013

This is nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment