Setup user auth packets
This commit is contained in:
1 parent
827b1285a9
commit
a78c040b09
3 files changed
+45
-3
No files matched your search
@@ -12,7 +12,7 @@ namespace Mistox.Client {
|
||||
public string ServerName { get; private set; } = ""; // The Name of the server
|
||||
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 bool isAuthenticated { get; private set; } = false; // Is the server authenticated
|
||||
public ConcurrentDictionary<IPEndPoint, mUDPClient> clientConnections { get; private set; } // UserName, Connection
|
||||
|
||||
public mTCPClient ServerConnection {get; private set; } // Global TCP Server Connection
|
||||
@@ -49,6 +49,13 @@ namespace Mistox.Client {
|
||||
});
|
||||
}
|
||||
|
||||
public async Task CheckAuthStatus(UserAuthPacket packet) {
|
||||
if (packet.AuthSuccessful == 1) {
|
||||
isAuthenticated = true;
|
||||
}
|
||||
ServerName = packet.ServerName;
|
||||
}
|
||||
|
||||
/////////////////////////////
|
||||
// Receive Methods
|
||||
/////////////////////////////
|
||||
@@ -91,6 +98,13 @@ namespace Mistox.Client {
|
||||
case UserDisconnectedPacket packet:
|
||||
UserDisconnected(packet);
|
||||
break;
|
||||
case UserAuthPacket packet:
|
||||
Task.Run(async () => {
|
||||
try {
|
||||
await CheckAuthStatus(packet);
|
||||
} catch {}
|
||||
});
|
||||
break;
|
||||
case null:
|
||||
Console.WriteLine("Received a null packet.");
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user