|
@@ -0,0 +1,25 @@
|
|
|
+using Hotline.Share.Dtos.Realtime;
|
|
|
+using Microsoft.AspNetCore.SignalR;
|
|
|
+using XF.Domain.Authentications;
|
|
|
+
|
|
|
+namespace Hotline.Api.Realtimes
|
|
|
+{
|
|
|
+ public class HotlineHub : Hub
|
|
|
+ {
|
|
|
+ public async Task JoinGroupAsync(JoinGroupDto dto)
|
|
|
+ {
|
|
|
+ await Groups.AddToGroupAsync(Context.ConnectionId, dto.GroupName);
|
|
|
+
|
|
|
+ await Clients.Group(dto.GroupName).SendAsync("Send", $"{Context.ConnectionId} has joined the group {dto.GroupName}.");
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task LeaveGroupAsync(JoinGroupDto dto)
|
|
|
+ {
|
|
|
+ await Groups.RemoveFromGroupAsync(Context.ConnectionId, dto.GroupName);
|
|
|
+
|
|
|
+ await Clients.Group(dto.GroupName).SendAsync("Send", $"{Context.ConnectionId} has left the group {dto.GroupName}.");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|