Changed CoreManager to contain new config property to enable/disable packet debugging

This commit is contained in:
Obique
2015-05-12 02:21:03 -05:00
committed by Obique
parent a215ee68d3
commit e2b7fb889b
2 changed files with 16 additions and 13 deletions
+2 -1
View File
@@ -13,4 +13,5 @@ MAX-PACKET-SIZE=496
SESSION-TOKEN-LENGTH=24
WIPE-ODB-FILES=1
ZONE-SERVER-ID=1
ZONE-SERVER-NAME=ZoneServer
ZONE-SERVER-NAME=ZoneServer
PACKET-DEBUG=true
+14 -12
View File
@@ -59,23 +59,14 @@ import services.galaxy.GalacticManager;
public class CoreManager extends Manager {
private static final int galaxyId = 1;
private static final boolean debugOutput = true;
private static PrintStream packetOutput;
static {
try {
packetOutput = new PrintStream(new FileOutputStream("packets.txt", false), true, "UTF-8");
} catch (FileNotFoundException | UnsupportedEncodingException e) {
e.printStackTrace();
packetOutput = System.out;
}
}
private EngineManager engineManager;
private GalacticManager galacticManager;
private PrintStream packetOutput;
private Galaxy galaxy;
private long startTime;
private boolean shutdownRequested;
private boolean packetDebug;
public CoreManager() {
shutdownRequested = false;
@@ -107,12 +98,14 @@ public class CoreManager extends Manager {
registerForIntent(InboundPacketIntent.TYPE);
registerForIntent(OutboundPacketIntent.TYPE);
registerForIntent(ServerManagementIntent.TYPE);
packetDebug = getConfig(ConfigFile.PRIMARY).getBoolean("PACKET-DEBUG", false);
initializePacketOutput();
return galaxy != null && super.initialize();
}
@Override
public void onIntentReceived(Intent i) {
if (debugOutput) {
if (packetDebug) {
if (i instanceof InboundPacketIntent) {
InboundPacketIntent in = (InboundPacketIntent) i;
packetOutput.println("IN " + in.getNetworkId() + ":" + in.getServerType());
@@ -127,6 +120,15 @@ public class CoreManager extends Manager {
handleServerManagementIntent((ServerManagementIntent) i);
}
private void initializePacketOutput() {
try {
packetOutput = new PrintStream(new FileOutputStream("packets.txt", false), true, "UTF-8");
} catch (FileNotFoundException | UnsupportedEncodingException e) {
e.printStackTrace();
packetOutput = System.out;
}
}
private void handleServerManagementIntent(ServerManagementIntent i) {
switch(i.getEvent()) {
case SHUTDOWN: initiateShutdownSequence(i.getTime()); break;