Set client name regardless of connection type

This commit is contained in:
Sanae 2022-03-06 17:19:49 -06:00
parent 9e1a53a231
commit 134437eec9
2 changed files with 2 additions and 2 deletions

View File

@ -23,7 +23,7 @@ public class Client : IDisposable {
public Client(Socket socket) {
Socket = socket;
Logger = new Logger(socket.RemoteEndPoint?.ToString() ?? "Unknown User???");
Logger = new Logger("Unknown User");
}
public void Dispose() {

View File

@ -146,6 +146,7 @@ public class Server {
ConnectPacket connect = new ConnectPacket();
connect.Deserialize(memory.Memory.Span[Constants.HeaderSize..Constants.MaxPacketSize]);
lock (Clients) {
client.Name = connect.ClientName;
bool firstConn = false;
switch (connect.ConnectionType) {
case ConnectionTypes.FirstConnection: {
@ -154,7 +155,6 @@ public class Server {
}
case ConnectionTypes.Reconnecting: {
client.Id = header.Id;
client.Name = connect.ClientName;
if (FindExistingClient(header.Id) is { } newClient) {
if (newClient.Connected) throw new Exception($"Tried to join as already connected user {header.Id}");
newClient.Socket = client.Socket;