Преглед изворни кода

root/trunk/L2J_Server_CT2.5/lib/mmocore.jar @ 5293

JIV пре 14 година
родитељ
комит
576aa1e5c5

+ 1 - 1
MMOCore/src/org/mmocore/network/MMOClient.java

@@ -23,7 +23,7 @@ import java.nio.ByteBuffer;
  * @author KenM
  * 
  */
-public abstract class MMOClient<T extends MMOConnection>
+public abstract class MMOClient<T extends MMOConnection<?>>
 {
 	private final T _con;
 	

+ 1 - 1
MMOCore/src/org/mmocore/network/MMOConnection.java

@@ -30,7 +30,7 @@ import java.nio.channels.WritableByteChannel;
  * @author KenM
  * 
  */
-public final class MMOConnection<T extends MMOClient<?>>
+public class MMOConnection<T extends MMOClient<?>>
 {
 	private final SelectorThread<T> _selectorThread;
 	

+ 18 - 12
MMOCore/src/org/mmocore/network/SelectorThread.java

@@ -437,21 +437,27 @@ public final class SelectorThread<T extends MMOClient<?>> extends Thread
 	private final void writeClosePacket(final MMOConnection<T> con)
 	{
 		SendablePacket<T> sp;
-		while ((sp = con.getSendQueue().removeFirst()) != null)
+		synchronized (con.getSendQueue())
 		{
-			WRITE_BUFFER.clear();
+			if (con.getSendQueue().isEmpty())
+				return;
 			
-			putPacketIntoWriteBuffer(con.getClient(), sp);
-			
-			WRITE_BUFFER.flip();
-			
-			try
+			while ((sp = con.getSendQueue().removeFirst()) != null)
 			{
-				con.write(WRITE_BUFFER);
-			}
-			catch (IOException e)
-			{
-				// error handling goes on the if bellow
+				WRITE_BUFFER.clear();
+				
+				putPacketIntoWriteBuffer(con.getClient(), sp);
+				
+				WRITE_BUFFER.flip();
+				
+				try
+				{
+					con.write(WRITE_BUFFER);
+				}
+				catch (IOException e)
+				{
+					// error handling goes on the if bellow
+				}
 			}
 		}
 	}