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

@@ -421,7 +421,7 @@ public class LoginServerThread extends Thread
return true;
}
savedClient.closeNow();
savedClient.disconnect();
_accountsInGameServer.remove(account);
return false;
}

View File

@@ -76,16 +76,6 @@ public class GameClient extends NetClient
@Override
public void onDisconnection()
{
LOGGER_ACCOUNTING.finer("Client disconnected: " + this);
LoginServerThread.getInstance().sendLogout(_accountName);
_connectionState = ConnectionState.DISCONNECTED;
super.onDisconnection();
}
public void closeNow()
{
onDisconnection();
synchronized (this)
{
if (_cleanupTask != null)
@@ -94,13 +84,17 @@ public class GameClient extends NetClient
}
_cleanupTask = ThreadPool.schedule(new CleanupTask(), 0); // delayed?
}
LOGGER_ACCOUNTING.finer("Client disconnected: " + this);
LoginServerThread.getInstance().sendLogout(_accountName);
_connectionState = ConnectionState.DISCONNECTED;
}
public void close(ServerPacket packet)
{
if (packet == null)
{
closeNow();
disconnect();
}
else
{
@@ -108,7 +102,7 @@ public class GameClient extends NetClient
sendPacket(packet);
// Wait for packet to be sent.
ThreadPool.schedule(this::closeNow, 1000);
ThreadPool.schedule(this::disconnect, 1000);
}
}
@@ -423,7 +417,7 @@ public class GameClient extends NetClient
if (player.getClient() != null)
{
player.getClient().closeNow();
player.getClient().disconnect();
}
else
{

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

@@ -56,7 +56,7 @@ public class AuthLogin implements ClientPacket
}
else
{
client.closeNow();
client.disconnect();
}
}
}

View File

@@ -40,7 +40,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 ((_version < Config.MIN_PROTOCOL_REVISION) || (_version > Config.MAX_PROTOCOL_REVISION))
{