Last active
June 26, 2018 14:58
-
-
Save gsedubun/e878980accac5042547047e70baf2817 to your computer and use it in GitHub Desktop.
simple SignalR chat hub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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