Impliment user auth on server

This commit is contained in:
derek.holloway committed 2026-08-04 08:55:33 -07:00
1 parent 007f87f986
commit 974b5c4f0a
2 files changed
+29 -14

No files matched your search

+9 -7
View File
@@ -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;
}
}
+20 -7
View File
@@ -1,16 +1,11 @@
using System;
using System.Net;
using System.Numerics;
using Mistox.Attributes;
namespace Mistox.ResevedPackets {
// Packet sent to clients when they are in range telling them to connect together
[mPacket]
public class UserConnectedPacket {
public string UserName { get; set; }
public IPAddress ClientIPAddress { get; set; }
}
// Implimented
// Packet send to server for Auth and responded to the client with Auth Success
[mPacket]
public class UserAuthPacket {
@@ -22,6 +17,7 @@ namespace Mistox.ResevedPackets {
public int AuthSuccessful { get; set; } = 0; // 0 is standard, -1 is auth failure, 1 is auth success
}
// Not Implimented
// Generic networked object packet
[mPacket]
public class EntityPacket {
@@ -34,6 +30,23 @@ namespace Mistox.ResevedPackets {
public byte[] InnerPayload { get; set; }
}
// Not implemented
// Packet sent to all clients when a users TCP stream connects to the server
[mPacket]
public class UserConnectedPacket {
public string UserName { get; set; }
public IPAddress ClientIPAddress { get; set; }
}
// Not implemented
// Packet sent to all clients when a global position update occurrs
[mPacket]
public class UserPositionUpdatePacket {
public string UserName { get; set; }
public Vector3 Position { get; set; }
}
// Not implimented
// Packet sent to all clients when a users TCP stream disconnects from the server
[mPacket]
public class UserDisconnectedPacket {