mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-21 09:02:07 -07:00
Potential overall stability improvements
This commit is contained in:
parent
7c2153ef3e
commit
187f7f087d
3 changed files with 21 additions and 10 deletions
|
|
@ -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() {
|
||||
tradeLogWriter?.flush()
|
||||
tradeLogWriter?.close()
|
||||
try {
|
||||
tradeLogWriter?.flush()
|
||||
tradeLogWriter?.close()
|
||||
} catch(ignored: Exception) {}
|
||||
}
|
||||
|
||||
fun getTime(): String{
|
||||
|
|
@ -76,10 +78,12 @@ object SystemLogger {
|
|||
|
||||
@JvmStatic
|
||||
fun logTrade(message: String){
|
||||
if(message.isNotBlank()){
|
||||
if(tradeLogWriter == null) logWarn("Trade Logger is null!")
|
||||
tradeLogWriter?.write("${getTime()}: $message")
|
||||
tradeLogWriter?.newLine()
|
||||
}
|
||||
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))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue