add(components): 添加MyInput组件

This commit is contained in:
2025-12-12 22:42:47 +08:00
parent d90366e304
commit fe4a9173a4
17 changed files with 721 additions and 498 deletions
+16 -9
View File
@@ -8,28 +8,35 @@ namespace IM_API.Hubs
{
public class ChatHub:Hub
{
private IJWTService _JWTService;
public ChatHub(IJWTService jWTService)
private IMessageSevice _messageService;
public ChatHub(IMessageSevice messageService)
{
_JWTService = jWTService;
_messageService = messageService;
}
public async override Task OnConnectedAsync()
{
var userIdStr = Context.User.FindFirstValue(ClaimTypes.NameIdentifier);
if(userIdStr is null)
if (!Context.User.Identity.IsAuthenticated)
{
await Clients.Caller.SendAsync("ReceiveMessage",new BaseResponse<object?>(CodeDefine.AUTH_FAILED));
Context.Abort();
return;
}
int userId = int.Parse(userIdStr);
await base.OnConnectedAsync();
}
public async Task SendMessage(MessageBaseDto dto)
public async Task SendPrivateMessage(MessageBaseDto dto)
{
await Clients.Caller.SendAsync("ReceiveMessage", "qwfqwfqw","test");
if (!Context.User.Identity.IsAuthenticated)
{
await Clients.Caller.SendAsync("ReceiveMessage", new BaseResponse<object?>(CodeDefine.AUTH_FAILED));
Context.Abort();
return;
}
var userIdStr = Context.User.FindFirstValue(ClaimTypes.NameIdentifier);
await _messageService.SendPrivateMessageAsync(int.Parse(userIdStr),dto.ReceiverId,dto);
await Clients.Caller.SendAsync("ReceiveMessage",userIdStr,"qfqwfqwfqw");
await Clients.Users(dto.ReceiverId.ToString()).SendAsync("ReceiveMessage", userIdStr, dto.Content);
return;
}
}
}