Added support for UUID.

The UUID will be sent before anything else upon connection to the Nexus so it can
associate the connection with a proper db entry.
This commit is contained in:
ProfMobius committed 2014-10-13 17:58:46 +02:00
1 parent e3aa9a4788
commit ea7ee7d2c8
3 files changed
+15 -3

No files matched your search

@@ -93,7 +93,8 @@ public enum Message {
CLIENT_CLEAR_SELECTION,
CLIENT_HIGHLIGHT_BLOCK,
SWING_TAB_CHANGED;
SWING_TAB_CHANGED,
NEXUS_UUID;
private AccessLevel accessLevel = AccessLevel.NONE;
private EnumSet<SelectedTab> tabEnum;
@@ -14,6 +14,7 @@ import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.util.SelfSignedCertificate;
import io.netty.handler.timeout.ReadTimeoutHandler;
import io.netty.handler.timeout.WriteTimeoutHandler;
import java.io.File;
import java.io.FileInputStream;
@@ -58,6 +59,7 @@ public class NexusClient implements Runnable {
//ch.pipeline().addLast(new RConHandshakeHandler());
//ch.pipeline().addLast(new JdkZlibDecoder());
//ch.pipeline().addLast(new JdkZlibEncoder());
//ch.pipeline().addLast(new WriteTimeoutHandler(5));
ch.pipeline().addLast(new NexusMsgDecoder());
ch.pipeline().addLast(new NexusInboundHandler());
}
@@ -78,6 +80,11 @@ public class NexusClient implements Runnable {
public void run(){
this.readConfig(this.reverseprop);
if (!this.active) return;
if (this.uuid.equals("")){
modOpis.log.error("UUID not set properly.");
return;
}
modOpis.log.info(String.format("Connecting to OpixNexus %s:%s", this.host, this.port));
EventLoopGroup workerGroup = new NioEventLoopGroup();
@@ -12,6 +12,7 @@ import com.mojang.authlib.GameProfile;
import mcp.mobius.opis.modOpis;
import mcp.mobius.opis.data.holders.basetypes.SerialLong;
import mcp.mobius.opis.data.holders.basetypes.SerialString;
import mcp.mobius.opis.data.managers.StringCache;
import mcp.mobius.opis.events.PlayerTracker;
import mcp.mobius.opis.network.PacketBase;
@@ -36,17 +37,20 @@ public class NexusInboundHandler extends ChannelInboundHandlerAdapter {
RConHandler.fakePlayers.put(fakePlayer, ctx);
PlayerTracker.INSTANCE.playersSwing.add(fakePlayer);
PlayerTracker.INSTANCE.playerTab.put(fakePlayer, SelectedTab.SUMMARY);
PlayerTracker.INSTANCE.playerTab.put(fakePlayer, SelectedTab.SUMMARY);
PacketManager.validateAndSend(new NetDataValue(Message.NEXUS_UUID, new SerialString(NexusClient.instance.uuid)), fakePlayer);
PacketManager.validateAndSend(new NetDataValue(Message.STATUS_CURRENT_TIME, new SerialLong(System.currentTimeMillis())), fakePlayer);
StringCache.INSTANCE.syncCache(fakePlayer);
modOpis.log.info(String.format("FakePlayer %s with uuid %s created.", ctx.name(), fakeUUID));
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace();
ctx.close();
}
}
}