0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-25 04:35:18 +00:00

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;