NetClient disconnect() should call onDisconnection().

This commit is contained in:
MobiusDevelopment
2023-07-27 04:01:10 +03:00
parent c449a89a83
commit a9c911e84d
250 changed files with 353 additions and 477 deletions

View File

@ -66,7 +66,6 @@ public class NetClient
*/
public void onDisconnection()
{
disconnect();
}
/**
@ -117,6 +116,9 @@ public class NetClient
{
_pendingData = null;
}
// Client is disconnected.
onDisconnection();
}
/**

View File

@ -240,6 +240,6 @@ public class ReadThread<E extends NetClient> implements Runnable
private void onDisconnection(E client)
{
_pool.remove(client);
client.onDisconnection();
client.disconnect();
}
}

View File

@ -125,7 +125,7 @@ public class SendThread<E extends NetClient> implements Runnable
catch (Exception e)
{
_pool.remove(_client);
_client.onDisconnection();
_client.disconnect();
break;
}
}

View File

@ -97,19 +97,13 @@ public class GameClient extends NetClient
Disconnection.of(this).onDisconnection();
}
_connectionState = ConnectionState.DISCONNECTED;
super.onDisconnection();
}
public void closeNow()
{
onDisconnection();
}
public void close(ServerPacket packet)
{
if (packet == null)
{
closeNow();
disconnect();
}
else
{
@ -117,7 +111,7 @@ public class GameClient extends NetClient
sendPacket(packet);
// Wait for packet to be sent.
ThreadPool.schedule(this::closeNow, 1000);
ThreadPool.schedule(this::disconnect, 1000);
}
}

View File

@ -43,7 +43,7 @@ public class PacketHandler implements PacketHandlerInterface<GameClient>
{
LOGGER.warning("PacketHandler: Problem receiving packet id from " + client);
LOGGER.warning(CommonUtil.getStackTrace(e));
client.closeNow();
client.disconnect();
return;
}

View File

@ -48,7 +48,7 @@ public class AuthLogin implements ClientPacket
{
if (_loginName.isEmpty() || !client.isProtocolOk())
{
client.closeNow();
client.disconnect();
return;
}

View File

@ -43,7 +43,7 @@ public class Logout implements ClientPacket
final Player player = client.getPlayer();
if (player == null)
{
client.closeNow();
client.disconnect();
return;
}

View File

@ -45,7 +45,7 @@ public class ProtocolVersion implements ClientPacket
if (_version == -2)
{
// This is just a ping attempt from the new C2 client.
client.closeNow();
client.disconnect();
}
else if (!Config.PROTOCOL_LIST.contains(_version))
{