3

In my site users can follow each other and when this event happened i want to show proper message for both users.

I found many solution like this and this but i cant use none, maybe i need more details :- .

In my site the userId is PK in DB and i store this in Session and userId of other users is embedded in html like this.

@foreeach(var item in Model)
{
     <div>@item.name</div>
     <button id="@item.userId">Follow</button> 
}

Startup.cs

    public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        var idProvider = new CustomUserIdProvider();

        GlobalHost.DependencyResolver.Register(typeof(IUserIdProvider), () => idProvider);          

        // Any connection or hub wire up and configuration should go here
        app.MapSignalR();
    }
}

myHub.cs

public class MyHub : Hub
{
     public void Send(string userId, string name, string message)
     {
          Clients.User(userId).broadcastMessage(name, "message 1");
          Clients.Caller.broadcastMessage(name, "message 2");

     }
}

In myHub.cs the userId is userId of target user that is to be followed? if yes how SignalR diagnose target user? I do not understand.

And in this solution that i have been found there is a CustomUserIdProvider class for find userId but i have userId of target user in a <button>

Whats the solution for my problem?

Community
  • 1
  • 1
distance
  • 824
  • 7
  • 19

0 Answers0