Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace P2PChat.Web.Hubs
- {
- using Microsoft.AspNetCore.Authorization;
- using Microsoft.AspNetCore.SignalR;
- using P2PChat.Web.Contracts;
- using System.Threading.Tasks;
- [Authorize]
- public class ChatHub : Hub
- {
- private readonly IChatConnectionService chatService;
- public ChatHub(IChatConnectionService userService)
- {
- this.chatService = userService;
- }
- public void Send(string name, string message)
- {
- //Clients.Client(chatService.GetConnectionId(name)).InvokeAsync("broadcastMessage", name, message);
- }
- public override Task OnConnectedAsync()
- {
- //Clients.All.InvokeAsync("broadcastMessage", "system", $"{Context.ConnectionId} joined the conversation");
- return base.OnConnectedAsync();
- }
- public override Task OnDisconnectedAsync(System.Exception exception)
- {
- //Clients.All.InvokeAsync("broadcastMessage", "system", $"{Context.ConnectionId} left the conversation");
- return base.OnDisconnectedAsync(exception);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement