Hasten login process a tad, maybe a 100ms saved for the user

This commit is contained in:
md_5 2013-02-08 16:21:08 +11:00
parent f1f68ab85b
commit 48447addba
3 changed files with 4 additions and 12 deletions

View File

@ -130,7 +130,7 @@ public class InitialHandler extends PacketHandler implements Runnable, PendingCo
{ {
Preconditions.checkState(thisState == State.LOGIN); Preconditions.checkState(thisState == State.LOGIN);
UserConnection userCon = new UserConnection(socket, this, in, out, handshake, new ArrayList<byte[]>()); UserConnection userCon = new UserConnection(socket, this, in, out, handshake);
String server = ProxyServer.getInstance().getReconnectHandler().getServer(userCon); String server = ProxyServer.getInstance().getReconnectHandler().getServer(userCon);
ServerInfo s = BungeeCord.getInstance().config.getServers().get(server); ServerInfo s = BungeeCord.getInstance().config.getServers().get(server);
userCon.connect(s); userCon.connect(s);

View File

@ -52,14 +52,9 @@ public class ServerConnection extends GenericConnection implements Server
OutputStream out = socket.getOutputStream(); OutputStream out = socket.getOutputStream();
out.write(handshake.getPacket()); out.write(handshake.getPacket());
out.write(new PacketCDClientStatus((byte) 0).getPacket());
in.readPacket(); in.readPacket();
for (byte[] custom : user.loginPackets)
{
out.write(custom);
}
out.write(new PacketCDClientStatus((byte) 0).getPacket());
byte[] loginResponse = in.readPacket(); byte[] loginResponse = in.readPacket();
if (Util.getId(loginResponse) == 0xFF) if (Util.getId(loginResponse) == 0xFF)
{ {

View File

@ -8,7 +8,6 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.Socket; import java.net.Socket;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
@ -23,7 +22,6 @@ import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.PendingConnection; import net.md_5.bungee.api.connection.PendingConnection;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.ChatEvent; import net.md_5.bungee.api.event.ChatEvent;
import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.api.event.ServerConnectEvent; import net.md_5.bungee.api.event.ServerConnectEvent;
@ -34,7 +32,6 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer
public final Packet2Handshake handshake; public final Packet2Handshake handshake;
public Queue<DefinedPacket> packetQueue = new ConcurrentLinkedQueue<>(); public Queue<DefinedPacket> packetQueue = new ConcurrentLinkedQueue<>();
public List<byte[]> loginPackets = new ArrayList<>();
@Getter @Getter
private final PendingConnection pendingConnection; private final PendingConnection pendingConnection;
@Getter @Getter
@ -55,14 +52,14 @@ public class UserConnection extends GenericConnection implements ProxiedPlayer
private final Map<String, Boolean> permissions = new HashMap<>(); private final Map<String, Boolean> permissions = new HashMap<>();
private final Object permMutex = new Object(); private final Object permMutex = new Object();
public UserConnection(Socket socket, PendingConnection pendingConnection, PacketInputStream in, OutputStream out, Packet2Handshake handshake, List<byte[]> loginPackets) public UserConnection(Socket socket, PendingConnection pendingConnection, PacketInputStream in, OutputStream out, Packet2Handshake handshake)
{ {
super(socket, in, out); super(socket, in, out);
this.handshake = handshake; this.handshake = handshake;
this.pendingConnection = pendingConnection; this.pendingConnection = pendingConnection;
name = handshake.username; name = handshake.username;
displayName = handshake.username; displayName = handshake.username;
this.loginPackets = loginPackets;
Collection<String> g = ProxyServer.getInstance().getConfigurationAdapter().getGroups(name); Collection<String> g = ProxyServer.getInstance().getConfigurationAdapter().getGroups(name);
for (String s : g) for (String s : g)
{ {