Will stop trying to reconnect once it received a CONNECTION_REFUSED packet.

This commit is contained in:
ProfMobius committed 2014-10-23 21:03:47 +02:00
1 parent 98d6df8312
commit 17ff3421fd
3 files changed
+12 -5

No files matched your search

@@ -99,7 +99,8 @@ public enum Message {
SWING_TAB_CHANGED,
NEXUS_UUID, // Login data for the nexus system
NEXUS_DATA, // Data blob with everything needed to update the summary screen in realtime
PLAYER_STATUS_UPDATE; // Update for the players (name, position, offline/online, etc)
PLAYER_STATUS_UPDATE, // Update for the players (name, position, offline/online, etc)
CONNECTION_REFUSED;
private AccessLevel accessLevel = AccessLevel.NONE;
private EnumSet<SelectedTab> tabEnum;
@@ -74,7 +74,8 @@ public class NexusClient implements Runnable {
String pass = "";
Integer port = 8013;
Boolean active = false;
public boolean reconnect = false;
public boolean reconnect = false;
public boolean shouldRetry = true;
public WeakReference<ChannelHandlerContext> ctx;
public final static NexusClient instance = new NexusClient();
@@ -115,7 +116,6 @@ public class NexusClient implements Runnable {
}
EventLoopGroup workerGroup = new NioEventLoopGroup();
boolean status = true;
try {
Bootstrap b = new Bootstrap(); // (1)
@@ -134,7 +134,7 @@ public class NexusClient implements Runnable {
workerGroup.shutdownGracefully();
}
return status;
return this.shouldRetry;
}
private void readConfig(String filename){
@@ -20,6 +20,7 @@ import mcp.mobius.opis.events.PlayerTracker;
import mcp.mobius.opis.network.PacketBase;
import mcp.mobius.opis.network.PacketManager;
import mcp.mobius.opis.network.enums.Message;
import mcp.mobius.opis.network.packets.client.PacketReqData;
import mcp.mobius.opis.network.packets.server.NetDataValue;
import mcp.mobius.opis.network.rcon.RConHandler;
import mcp.mobius.opis.network.rcon.server.RConServer;
@@ -55,7 +56,12 @@ public class NexusInboundHandler extends ChannelInboundHandlerAdapter {
try {
FakePlayer fakePlayer = RConHandler.fakePlayersNexus.inverse().get(ctx);
PacketBase packet = (PacketBase) msg;
packet.actionServer(null, fakePlayer);
if (packet instanceof PacketReqData && ((PacketReqData)packet).dataReq == Message.CONNECTION_REFUSED){
modOpis.log.error(String.format("Connection refused. Wrong uuid or pass."));
NexusClient.instance.shouldRetry = false;
}else{
packet.actionServer(null, fakePlayer);
}
} finally {
ReferenceCountUtil.release(msg);
}