startit/Emne 3/DependencyInversionPrinciple/DIP.ChatServer/ChatServer.cs
Geir Okkenhaug Jerstad 4d4146e197 Start Clicker oop
2025-01-08 10:32:47 +01:00

28 lines
464 B
C#

namespace DIP.ChatServer;
public class ChatServer
{
private readonly List<IChatClient> _clients;
public ChatServer()
{
_clients = new List<IChatClient>();
}
public void Broadcast(IChatClient client, string message)
{
foreach (var chatClient in _clients)
{
if (chatClient != client)
{
chatClient.Receive(message);
}
}
}
public void Register(IChatClient client)
{
_clients.Add(client);
}
}