Building chat application using SignalR, I'm new with SignalR, started with Tutorial: Getting Started with SignalR 2 and MVC 5
Everything passed fine, now I want impliment Application User Name as sender, when I use method like this:
$('#displayname').val('@Context.User.Identity.Name');
Hub gets current loged in username and displays it on page, here is my Hub Code:
[HubName("chatHub")]
public class ChatHub : Hub
{
public void Send(string name, string message)
{
Clients.All.addNewMessageToPage(name, message);
}
}
Now I want impliment username with another method, this method is described Here
Code below not working, can anyone explain why, I want to understant to know method how to use SingalR. Here is code that not works:
[HubName("chatHub")]
public class ChatHub : Hub
{
public void Send(string name, string message)
{
name = Context.User.Identity.Name;
Clients.All.addNewMessageToPage(name, message);
}
}
Lot of thanks and sorry for my English.
Aucun commentaire:
Enregistrer un commentaire