13
0
geforkt von Mirrors/Velocity

Correctly handle rapid disconnects. Fixes #31

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-08-11 06:46:40 -04:00
Ursprung 8068f72729
Commit 21e72556c9
3 geänderte Dateien mit 23 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -104,19 +104,22 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter {
} }
public void write(Object msg) { public void write(Object msg) {
ensureOpen(); if (channel.isActive()) {
channel.writeAndFlush(msg, channel.voidPromise()); channel.writeAndFlush(msg, channel.voidPromise());
} }
}
public void delayedWrite(Object msg) { public void delayedWrite(Object msg) {
ensureOpen(); if (channel.isActive()) {
channel.write(msg, channel.voidPromise()); channel.write(msg, channel.voidPromise());
} }
}
public void flush() { public void flush() {
ensureOpen(); if (channel.isActive()) {
channel.flush(); channel.flush();
} }
}
public void closeWith(Object msg) { public void closeWith(Object msg) {
if (channel.isActive()) { if (channel.isActive()) {

Datei anzeigen

@ -18,6 +18,13 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
@Override @Override
public void handle(MinecraftPacket packet) { public void handle(MinecraftPacket packet) {
if (!connection.getProxyPlayer().isActive()) {
// Connection was left open accidentally. Close it so as to avoid "You logged in from another location"
// errors.
connection.getMinecraftConnection().close();
return;
}
ClientPlaySessionHandler playerHandler = ClientPlaySessionHandler playerHandler =
(ClientPlaySessionHandler) connection.getProxyPlayer().getConnection().getSessionHandler(); (ClientPlaySessionHandler) connection.getProxyPlayer().getConnection().getSessionHandler();
if (packet instanceof KeepAlive) { if (packet instanceof KeepAlive) {
@ -69,6 +76,13 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler {
@Override @Override
public void handleUnknown(ByteBuf buf) { public void handleUnknown(ByteBuf buf) {
if (!connection.getProxyPlayer().isActive()) {
// Connection was left open accidentally. Close it so as to avoid "You logged in from another location"
// errors.
connection.getMinecraftConnection().close();
return;
}
ClientPlaySessionHandler playerHandler = ClientPlaySessionHandler playerHandler =
(ClientPlaySessionHandler) connection.getProxyPlayer().getConnection().getSessionHandler(); (ClientPlaySessionHandler) connection.getProxyPlayer().getConnection().getSessionHandler();
ByteBuf remapped = playerHandler.getIdRemapper().remap(buf, ProtocolConstants.Direction.CLIENTBOUND); ByteBuf remapped = playerHandler.getIdRemapper().remap(buf, ProtocolConstants.Direction.CLIENTBOUND);

Datei anzeigen

@ -132,7 +132,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
String error = ThrowableUtils.briefDescription(throwable); String error = ThrowableUtils.briefDescription(throwable);
String userMessage; String userMessage;
if (connectedServer != null && connectedServer.getServerInfo().equals(info)) { if (connectedServer != null && connectedServer.getServerInfo().equals(info)) {
logger.error("{}: exception occurred in connection to {}", this, info.getName(), throwable);
userMessage = "Exception in server " + info.getName(); userMessage = "Exception in server " + info.getName();
} else { } else {
logger.error("{}: unable to connect to server {}", this, info.getName(), throwable); logger.error("{}: unable to connect to server {}", this, info.getName(), throwable);