Tons of minor fixes
This commit is contained in:
1 parent
873a6fa455
commit
37a6b5d59b
12 files changed
+219
-147
No files matched your search
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
using Mistox.Client;
|
||||
@@ -15,7 +14,7 @@ namespace Mistox {
|
||||
public event Action<mUDPClient> onUserDisconnected;
|
||||
public event Action onServerDisconnected;
|
||||
|
||||
public ClientInterface( string IpOrHostName, int Port ) {
|
||||
public ClientInterface( string UserName, string ConnectionKey, string IpOrHostName, int Port ) {
|
||||
|
||||
// Get Server IP
|
||||
IPHostEntry host = Dns.GetHostEntry( IpOrHostName );
|
||||
@@ -27,7 +26,7 @@ namespace Mistox {
|
||||
}
|
||||
|
||||
// Start and wire up the Mistox server client
|
||||
serverInstance = new MistoxClient( ServerDenstination );
|
||||
serverInstance = new MistoxClient( UserName, ConnectionKey, ServerDenstination );
|
||||
serverInstance.onServerConnected += onServerConnected;
|
||||
serverInstance.onUserConnected += (mUDPClient endpoint) => { onUserConnected?.Invoke(endpoint); };
|
||||
serverInstance.onDataReceived += (dynamic data) => { onDataReceived?.Invoke(data); };
|
||||
@@ -36,15 +35,15 @@ namespace Mistox {
|
||||
}
|
||||
|
||||
public async Task SendAllClients<Packet>(Packet data) {
|
||||
foreach( KeyValuePair<UInt128, mUDPClient> cur in serverInstance.clientConnections ){
|
||||
await cur.Value.Send( data );
|
||||
foreach( mUDPClient cur in serverInstance.clientConnections.Values ){
|
||||
await cur.Send( data );
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SendClient<Packet>(string UserName, Packet data) {
|
||||
foreach( KeyValuePair<UInt128, mUDPClient> cur in serverInstance.clientConnections) {
|
||||
if (cur.Value.UserName.ToLower() == UserName.ToLower()) {
|
||||
await cur.Value.Send( data );
|
||||
foreach( mUDPClient cur in serverInstance.clientConnections.Values ) {
|
||||
if (cur.UserName.ToLower() == UserName.ToLower()) {
|
||||
await cur.Send( data );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user