Reputation: 1589
I'm trying to send the user that connects a welcome message, but something like this won't work:
public void Connected(string name)
{
Clients.this.newMessage("Hello world!"); //Welcome message to current user
Clients.All.userConnected(name); //Joined message to everyone
}
I know it's not a lot of information I give you, but I don't know what you need. (My front end is with angularJs, that might be useful)
Upvotes: 0
Views: 85
Reputation: 5745
You can do something like this
public override Task OnConnected()
{
string name = Context.User.Identity.Name;
Groups.Add(Context.ConnectionId, name);
Clients.Group(name).newMessage("Hello world!"); //Welcome message to current user
return base.OnConnected();
}
Upvotes: 1