Dagen slutt
This commit is contained in:
parent
8dfac53540
commit
6361e14b88
6 changed files with 37 additions and 2 deletions
|
@ -0,0 +1,28 @@
|
|||
namespace DIP.ChatServer;
|
||||
|
||||
public class ChatServer
|
||||
{
|
||||
private readonly List<ChatClient> _clients;
|
||||
|
||||
public ChatServer()
|
||||
{
|
||||
_clients = new List<ChatClient>();
|
||||
}
|
||||
|
||||
public void Broadcast(ChatClient client, string message)
|
||||
{
|
||||
foreach (var chatClient in _clients)
|
||||
{
|
||||
if (chatClient != client)
|
||||
{
|
||||
chatClient.Receive(message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void Register(ChatClient client)
|
||||
{
|
||||
_clients.Add(client);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
Loading…
Add table
Add a link
Reference in a new issue