refactor and chat base

This commit is contained in:
2023-04-22 12:42:02 +02:00
parent 2c7e7303bc
commit e4769d4b99
11 changed files with 231 additions and 144 deletions

22
Room/Chat/Chat.cs Normal file
View File

@@ -0,0 +1,22 @@
using System.Net.WebSockets;
using System.Text.Json;
using MauMau_Server.Websockets;
namespace MauMau_Server.Mau;
public class Chat
{
private readonly Room _room;
public Chat(Room room)
{
_room = room;
}
public void SendChatMessage(string connectionId, string message)
{
var chatMessage = new ChatOutput(connectionId, message);
var formattedMessage = new MessageDTO("CHAT", JsonSerializer.Serialize(chatMessage));
WebsocketManager.BroadcastAsync(_room.GetWebsockets(), JsonSerializer.Serialize(formattedMessage));
}
}