Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / Signalr отправка сообщений по UserID / 1 сообщений из 1, страница 1 из 1
08.01.2015, 11:20
    #38850064
Andrey1306
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Signalr отправка сообщений по UserID
Добрый день.

Как сменить привязку в Signalr hub username => connectionid , отправки сообщений. на userid => connectionid.

Сейчас сделано так , неудобно когда сообщения нужно отправлять зная userid.

Код: c#
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
 public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);
            var unityHubActivator = new MvcHubActivator();

            GlobalHost.DependencyResolver.Register(typeof(IHubActivator),   () =>  unityHubActivator);

            app.MapSignalR();
        }
    }


    public class MvcHubActivator : IHubActivator
    {
        public IHub Create(HubDescriptor descriptor)
        {
            return (IHub)DependencyResolver.Current.GetService(descriptor.HubType);
        }
       
    }



Вычитал такое

SignalR provides ConnectionId for each connection. To find which connection belongs to whom (the user), we need to create a mapping between the connection and the user. This depends on how you identify a user in your application.

In SignalR 2.0, this is done by using the inbuilt IPrincipal.Identity.Name, which is the logged in user identifier as set during the ASP.NET authentication.

However, you may need to map the connection with the user using a different identifier instead of using the Identity.Name. For this purpose this new provider can be used with your custom implementation for mapping user with the connection.

тут


но что то не осилю найти как привязку сменить .

вообщем нужен бест вей, отправки сообщений пользователю, зная userid

Спасибо.
...
Рейтинг: 0 / 0
Форумы / ASP.NET [игнор отключен] [закрыт для гостей] / Signalr отправка сообщений по UserID / 1 сообщений из 1, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]