Part of the last commit

This commit is contained in:
derek.holloway committed 2026-08-03 13:26:46 -07:00
1 parent 46efb5bd65
commit ad5b903d36
1 file changed
+21 -1
+21 -1
View File
@@ -13,7 +13,7 @@ namespace Mistox.Client {
public string UserName { get; private set; } = ""; // My UserName
public bool Alive { get; set; } = true; // Is the server running
public bool isAuthenticated { get; set; } = false; // Is the server authenticated
public ConcurrentDictionary<IPEndPoint, mUDPClient> clientConnections; // UserName, Connection
public ConcurrentDictionary<IPEndPoint, mUDPClient> clientConnections { get; private set; } // UserName, Connection
public mTCPClient ServerConnection {get; private set; } // Global TCP Server Connection
public UdpClient ClientSocket { get; private set; } // Global UDP Sender
@@ -126,6 +126,26 @@ namespace Mistox.Client {
Alive = false;
onServerDisconnected?.Invoke();
}
public async Task SendAllClients<Packet>(Packet data) {
foreach( mUDPClient cur in clientConnections.Values ){
await cur.Send( data );
}
}
public async Task SendClient<Packet>(string UserName, Packet data) {
foreach( mUDPClient cur in clientConnections.Values ) {
if (cur.UserName.ToLower() == UserName.ToLower()) {
await cur.Send( data );
break;
}
}
}
public async Task SendServer<Packet>(Packet data) {
await ServerConnection.Send( data );
}
}
}