Caching of handshake data should work
This commit is contained in:
parent
4e4cead245
commit
c095c04756
|
|
@ -0,0 +1,9 @@
|
|||
package org.adde0109.ambassador;
|
||||
|
||||
public class ForgeConnectionHandler {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -28,7 +28,7 @@ public class ForgeHandshakeDataHandler {
|
|||
public byte[] recivedClientACK;
|
||||
public byte[] recivedClientModlist;
|
||||
|
||||
private static final int PACKET_LENGTH_INDEX = 14;
|
||||
private static final int PACKET_LENGTH_INDEX = 14; //length of "fml:handshake"+1
|
||||
|
||||
private final Logger logger;
|
||||
private RegisteredServer handshakeServer;
|
||||
|
|
@ -40,14 +40,20 @@ public class ForgeHandshakeDataHandler {
|
|||
|
||||
@Subscribe(order = PostOrder.EARLY)
|
||||
public void onPreLogin(PreLoginEvent event, Continuation continuation) {
|
||||
if (cachedServerHandshake == null) {
|
||||
if(handshakeServer.getPlayersConnected().isEmpty()) {
|
||||
handshakeReceiver receiver = new handshakeReceiver(handshakeServer, logger);
|
||||
receiver.downloadHandshake().thenAccept((p) -> {
|
||||
cachedServerHandshake = p;
|
||||
sendModlist(p.modListPacket,(LoginPhaseConnection) event.getConnection());
|
||||
sendOther(p.otherPackets,(LoginPhaseConnection) event.getConnection());
|
||||
continuation.resume();
|
||||
});
|
||||
}
|
||||
else if(cachedServerHandshake != null) {
|
||||
sendModlist(cachedServerHandshake.modListPacket, (LoginPhaseConnection) event.getConnection());
|
||||
sendOther(cachedServerHandshake.otherPackets,(LoginPhaseConnection) event.getConnection());
|
||||
continuation.resume();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user