forked from SoDOff-Project/sodoff-mmo
more fixes
This commit is contained in:
parent
d162ce80aa
commit
30cbc54eca
@ -35,7 +35,12 @@ public class Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Send(NetworkPacket packet) {
|
public void Send(NetworkPacket packet) {
|
||||||
|
try {
|
||||||
socket.Send(packet.SendData);
|
socket.Send(packet.SendData);
|
||||||
|
} catch (SocketException) {
|
||||||
|
LeaveRoom();
|
||||||
|
SheduleDisconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LeaveRoom() {
|
public void LeaveRoom() {
|
||||||
|
@ -31,8 +31,9 @@ public class Server {
|
|||||||
listener.Listen(100);
|
listener.Listen(100);
|
||||||
while (true) {
|
while (true) {
|
||||||
Socket handler = await listener.AcceptAsync();
|
Socket handler = await listener.AcceptAsync();
|
||||||
|
handler.SendTimeout = 200;
|
||||||
Console.WriteLine($"New connection from {((IPEndPoint)handler.RemoteEndPoint!).Address}");
|
Console.WriteLine($"New connection from {((IPEndPoint)handler.RemoteEndPoint!).Address}");
|
||||||
_ = HandleClient(handler);
|
_ = Task.Run(() => HandleClient(handler));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +46,7 @@ public class Server {
|
|||||||
while (client.TryGetNextPacket(out NetworkPacket packet))
|
while (client.TryGetNextPacket(out NetworkPacket packet))
|
||||||
networkObjects.Add(packet.GetObject());
|
networkObjects.Add(packet.GetObject());
|
||||||
|
|
||||||
_ = Task.Run(() => HandleObjects(networkObjects, client));
|
HandleObjects(networkObjects, client);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
@ -62,13 +63,13 @@ public class Server {
|
|||||||
short commandId = obj.Get<short>("a");
|
short commandId = obj.Get<short>("a");
|
||||||
ICommandHandler handler;
|
ICommandHandler handler;
|
||||||
if (commandId != 13) {
|
if (commandId != 13) {
|
||||||
|
if (commandId == 0 || commandId == 1)
|
||||||
Console.WriteLine($"System command: {commandId} IID: {client.ClientID}");
|
Console.WriteLine($"System command: {commandId} IID: {client.ClientID}");
|
||||||
handler = moduleManager.GetCommandHandler(commandId);
|
handler = moduleManager.GetCommandHandler(commandId);
|
||||||
} else
|
} else
|
||||||
handler = moduleManager.GetCommandHandler(obj.Get<NetworkObject>("p").Get<string>("c"));
|
handler = moduleManager.GetCommandHandler(obj.Get<NetworkObject>("p").Get<string>("c"));
|
||||||
handler.Handle(client, obj.Get<NetworkObject>("p"));
|
handler.Handle(client, obj.Get<NetworkObject>("p"));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
if (!ex.Message.Contains("ID 7")) // Missing command 7 flooding the log
|
|
||||||
Console.WriteLine($"Exception IID: {client.ClientID} - {ex}");
|
Console.WriteLine($"Exception IID: {client.ClientID} - {ex}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user