Skip to content

Instantly share code, notes, and snippets.

@gsedubun
Last active June 26, 2018 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsedubun/e878980accac5042547047e70baf2817 to your computer and use it in GitHub Desktop.
Save gsedubun/e878980accac5042547047e70baf2817 to your computer and use it in GitHub Desktop.
simple SignalR chat hub
public class ChatHub : Hub
{
public void Send(string message)
{
Clients.All.SendAsync("SendMessage", Context.User.Identity.Name, message);
}
public override async Task OnConnectedAsync(){
await Clients.All.SendAsync("SendAction", Context.User.Identity.Name, "joined");
}
public override async Task OnDisconnectedAsync(System.Exception exception){
await Clients.All.SendAsync("SendAction", Context.User.Identity.Name, "left");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment