Added BoardcastMessage, Username Changed event via Broadcast, remove json parsing from ChatMessage

This commit is contained in:
Patrick Hellebrand
2021-09-23 10:56:10 +02:00
parent f2b0af08c5
commit 871ed22956
4 changed files with 33 additions and 25 deletions

View File

@@ -80,6 +80,15 @@ namespace PolyChat
});
}
public void SendBroadcastMessage(string type, string content)
{
Debug.WriteLine("--- Controller.Broadcast ---");
foreach (KeyValuePair<string, Connection> entry in Connections)
{
SendMessage(entry.Key, type, content);
}
}
public void SendMessage(string ip, string type, string content)
{
Debug.WriteLine("--- Controller.SendMessage ---");
@@ -111,7 +120,7 @@ namespace PolyChat
Connections[IP].Close();
Connections.Remove(IP);
}
CloseChatUI(IP,wasConnected);
CloseChatUI(IP, wasConnected);
}
private void CloseChatUI(string IP, bool wasConnected = true)
@@ -123,7 +132,7 @@ namespace PolyChat
private bool isInConnections(string IP)
{
if(Connections.ContainsKey(IP))
if (Connections.ContainsKey(IP))
return true;
return false;
}