Part of the last commit
This commit is contained in:
1 parent
46efb5bd65
commit
ad5b903d36
1 file changed
+21
-1
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user