Addition of GameClient pending packet queue.
This commit is contained in:
		| @@ -21,6 +21,8 @@ import java.sql.Connection; | ||||
| import java.sql.PreparedStatement; | ||||
| import java.sql.ResultSet; | ||||
| import java.util.List; | ||||
| import java.util.Queue; | ||||
| import java.util.concurrent.ConcurrentLinkedQueue; | ||||
| import java.util.concurrent.locks.ReentrantLock; | ||||
| import java.util.logging.Level; | ||||
| import java.util.logging.Logger; | ||||
| @@ -54,6 +56,7 @@ public class GameClient extends NetClient | ||||
| { | ||||
| 	protected static final Logger LOGGER_ACCOUNTING = Logger.getLogger("accounting"); | ||||
| 	 | ||||
| 	private final Queue<ServerPacket> _pendingPackets = new ConcurrentLinkedQueue<>(); | ||||
| 	private final FloodProtectors _floodProtectors = new FloodProtectors(this); | ||||
| 	private final ReentrantLock _playerLock = new ReentrantLock(); | ||||
| 	private ConnectionState _connectionState = ConnectionState.CONNECTED; | ||||
| @@ -191,6 +194,22 @@ public class GameClient extends NetClient | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 		if (Config.PACKET_ENCRYPTION) | ||||
| 		{ | ||||
| 			_pendingPackets.add(packet); | ||||
| 			synchronized (_pendingPackets) | ||||
| 			{ | ||||
| 				writePacket(_pendingPackets.poll()); | ||||
| 			} | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			writePacket(packet); | ||||
| 		} | ||||
| 	} | ||||
| 	 | ||||
| 	private void writePacket(ServerPacket packet) | ||||
| 	{ | ||||
| 		try | ||||
| 		{ | ||||
| 			if ((getChannel() != null) && getChannel().isConnected()) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 MobiusDevelopment
					MobiusDevelopment