Impliment user auth on server
This commit is contained in:
1 parent
007f87f986
commit
974b5c4f0a
2 files changed
+29
-14
No files matched your search
@@ -49,21 +49,23 @@ namespace Mistox.Server {
|
||||
onUserConnected?.Invoke( user );
|
||||
}
|
||||
|
||||
public event Action<dynamic> onDataReceived;
|
||||
public event Action<ServerConnection, dynamic> onDataReceived;
|
||||
public void InvokeDataReceived( ServerConnection user, dynamic data ){
|
||||
switch (data as object) {
|
||||
case UserAuthPacket packet:
|
||||
Task.Run(async () => {
|
||||
try {
|
||||
await ProcessAuthRequest(user, packet);
|
||||
} catch {}
|
||||
});
|
||||
if (!user.IsAuthenticated) {
|
||||
Task.Run(async () => {
|
||||
try {
|
||||
await ProcessAuthRequest(user, packet);
|
||||
} catch {}
|
||||
});
|
||||
}
|
||||
break;
|
||||
case null:
|
||||
Console.WriteLine("Received a null packet.");
|
||||
break;
|
||||
default:
|
||||
onDataReceived?.Invoke(data);
|
||||
onDataReceived?.Invoke(user, data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user