mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-25 12:45:18 +00:00
Set client name regardless of connection type
This commit is contained in:
parent
9e1a53a231
commit
134437eec9
2 changed files with 2 additions and 2 deletions
|
@ -23,7 +23,7 @@ public class Client : IDisposable {
|
||||||
|
|
||||||
public Client(Socket socket) {
|
public Client(Socket socket) {
|
||||||
Socket = socket;
|
Socket = socket;
|
||||||
Logger = new Logger(socket.RemoteEndPoint?.ToString() ?? "Unknown User???");
|
Logger = new Logger("Unknown User");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose() {
|
public void Dispose() {
|
||||||
|
|
|
@ -146,6 +146,7 @@ public class Server {
|
||||||
ConnectPacket connect = new ConnectPacket();
|
ConnectPacket connect = new ConnectPacket();
|
||||||
connect.Deserialize(memory.Memory.Span[Constants.HeaderSize..Constants.MaxPacketSize]);
|
connect.Deserialize(memory.Memory.Span[Constants.HeaderSize..Constants.MaxPacketSize]);
|
||||||
lock (Clients) {
|
lock (Clients) {
|
||||||
|
client.Name = connect.ClientName;
|
||||||
bool firstConn = false;
|
bool firstConn = false;
|
||||||
switch (connect.ConnectionType) {
|
switch (connect.ConnectionType) {
|
||||||
case ConnectionTypes.FirstConnection: {
|
case ConnectionTypes.FirstConnection: {
|
||||||
|
@ -154,7 +155,6 @@ public class Server {
|
||||||
}
|
}
|
||||||
case ConnectionTypes.Reconnecting: {
|
case ConnectionTypes.Reconnecting: {
|
||||||
client.Id = header.Id;
|
client.Id = header.Id;
|
||||||
client.Name = connect.ClientName;
|
|
||||||
if (FindExistingClient(header.Id) is { } newClient) {
|
if (FindExistingClient(header.Id) is { } newClient) {
|
||||||
if (newClient.Connected) throw new Exception($"Tried to join as already connected user {header.Id}");
|
if (newClient.Connected) throw new Exception($"Tried to join as already connected user {header.Id}");
|
||||||
newClient.Socket = client.Socket;
|
newClient.Socket = client.Socket;
|
||||||
|
|
Loading…
Reference in a new issue