Potential overall stability improvements
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package core.net;
|
||||
|
||||
import rs09.game.system.SystemLogger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.channels.*;
|
||||
@@ -58,8 +60,14 @@ public class IoEventHandler {
|
||||
ByteBuffer buffer = ByteBuffer.allocate(100_000);
|
||||
IoSession session = (IoSession) key.attachment();
|
||||
if (channel.read(buffer) == -1) {
|
||||
//just when a client closes their client, nothing to worry about.
|
||||
throw new IOException("An existing connection was disconnected!");
|
||||
if(session != null){
|
||||
if(session.getPlayer() != null){
|
||||
SystemLogger.logInfo("Connection closed - disconnecting player.");
|
||||
session.getPlayer().clear();
|
||||
}
|
||||
//key.cancel();
|
||||
return;
|
||||
}
|
||||
}
|
||||
buffer.flip();
|
||||
if (session == null) {
|
||||
|
||||
@@ -29,8 +29,10 @@ object SystemLogger {
|
||||
|
||||
@JvmStatic()
|
||||
fun flushLogs() {
|
||||
try {
|
||||
tradeLogWriter?.flush()
|
||||
tradeLogWriter?.close()
|
||||
} catch(ignored: Exception) {}
|
||||
}
|
||||
|
||||
fun getTime(): String{
|
||||
@@ -76,10 +78,12 @@ object SystemLogger {
|
||||
|
||||
@JvmStatic
|
||||
fun logTrade(message: String){
|
||||
try {
|
||||
if (message.isNotBlank()) {
|
||||
if (tradeLogWriter == null) logWarn("Trade Logger is null!")
|
||||
tradeLogWriter?.write("${getTime()}: $message")
|
||||
tradeLogWriter?.newLine()
|
||||
}
|
||||
} catch(ignored: Exception){}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@ object PacketWriteQueue {
|
||||
|
||||
@JvmStatic
|
||||
fun <T> queue(packet: OutgoingPacket<T>, context: T){
|
||||
SystemLogger.logInfo(packet.javaClass.simpleName)
|
||||
PacketsToWrite.add(QueuedPacket(packet,context))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user