mirror of
https://gitee.com/xiarenalofs/squad-rain-ops-mini.git
synced 2026-08-06 05:16:26 +08:00
23 lines
671 B
C#
23 lines
671 B
C#
using Microsoft.AspNetCore.SignalR;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace RainOpsMini.Hubs
|
|
{
|
|
public class ChatHub : Hub
|
|
{
|
|
public async Task SendMessage(string user, string message)
|
|
{
|
|
var principal = Context.User;
|
|
if (principal == null ||
|
|
(!principal.HasClaim("Permission", "chat") &&
|
|
!principal.HasClaim("Permission", "all") &&
|
|
principal.FindFirst("IsSuperAdmin")?.Value != "true"))
|
|
{
|
|
throw new HubException("访问被拒绝:权限不足。");
|
|
}
|
|
|
|
await Clients.All.SendAsync("ReceiveMessage", user, message);
|
|
}
|
|
}
|
|
}
|