Start Clicker oop

This commit is contained in:
Geir Okkenhaug Jerstad 2025-01-08 10:32:47 +01:00
parent 6361e14b88
commit 4d4146e197
6 changed files with 41 additions and 5 deletions

View file

@ -2,14 +2,14 @@ namespace DIP.ChatServer;
public class ChatServer
{
private readonly List<ChatClient> _clients;
private readonly List<IChatClient> _clients;
public ChatServer()
{
_clients = new List<ChatClient>();
_clients = new List<IChatClient>();
}
public void Broadcast(ChatClient client, string message)
public void Broadcast(IChatClient client, string message)
{
foreach (var chatClient in _clients)
{
@ -21,7 +21,7 @@ public class ChatServer
}
}
public void Register(ChatClient client)
public void Register(IChatClient client)
{
_clients.Add(client);
}

View file

@ -0,0 +1,6 @@
namespace DIP.ChatServer;
public interface IChatClient
{
void Receive(string message);
}

View file

@ -1,6 +1,7 @@
namespace DependencyInversionPrinciple;
using DIP.ChatServer;
public class ChatClient
public class ChatClient : IChatClient
{
private readonly string _name;
private readonly ChatServer _server;