Добавил класс для представления сообщения

This commit is contained in:
2026-08-29 00:26:24 +03:00
parent 71b377f214
commit 0bea967bcf
2 changed files with 12 additions and 3 deletions
+4 -3
View File
@@ -1,3 +1,4 @@
using AMessanger.Core.Models;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@@ -5,9 +6,9 @@ namespace AMessanger.Core.Hubs;
public class ChatHub(ILogger<ChatHub> logger) : Hub public class ChatHub(ILogger<ChatHub> logger) : Hub
{ {
public async Task SendMessage(string user, string message) public async Task SendMessage(Message message)
{ {
logger.LogInformation($"{user}: {message}"); logger.LogInformation($"{message.UserName}: {message.Content}");
await Clients.All.SendAsync("ReceiveMessage", user, message); await Clients.All.SendAsync("ReceiveMessage", message);
} }
} }
+8
View File
@@ -0,0 +1,8 @@
namespace AMessanger.Core.Models
{
public class Message(string userName, string content)
{
public string UserName { get; set; } = userName;
public string Content { get; set; } = content;
}
}