Start Clicker oop
This commit is contained in:
parent
6361e14b88
commit
4d4146e197
6 changed files with 41 additions and 5 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
namespace DIP.ChatServer;
|
||||
|
||||
public interface IChatClient
|
||||
{
|
||||
void Receive(string message);
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
namespace DependencyInversionPrinciple;
|
||||
using DIP.ChatServer;
|
||||
|
||||
public class ChatClient
|
||||
public class ChatClient : IChatClient
|
||||
{
|
||||
private readonly string _name;
|
||||
private readonly ChatServer _server;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue