Move client transition state and hostAddress to fields
This commit is contained in:
@@ -62,6 +62,7 @@ import tools.data.input.GenericSeekableLittleEndianAccessor;
|
|||||||
import javax.script.ScriptEngine;
|
import javax.script.ScriptEngine;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
@@ -81,7 +82,10 @@ public class MapleClient extends ChannelInboundHandlerAdapter {
|
|||||||
public static final String CLIENT_HWID = "HWID";
|
public static final String CLIENT_HWID = "HWID";
|
||||||
public static final String CLIENT_NIBBLEHWID = "HWID2";
|
public static final String CLIENT_NIBBLEHWID = "HWID2";
|
||||||
public static final String CLIENT_REMOTE_ADDRESS = "REMOTE_IP";
|
public static final String CLIENT_REMOTE_ADDRESS = "REMOTE_IP";
|
||||||
public static final String CLIENT_TRANSITION = "TRANSITION";
|
|
||||||
|
private String hostAddress;
|
||||||
|
private volatile boolean inTransition;
|
||||||
|
|
||||||
private MapleAESOFB send;
|
private MapleAESOFB send;
|
||||||
private MapleAESOFB receive;
|
private MapleAESOFB receive;
|
||||||
private final IoSession session;
|
private final IoSession session;
|
||||||
@@ -143,6 +147,17 @@ public class MapleClient extends ChannelInboundHandlerAdapter {
|
|||||||
this.session = session;
|
this.session = session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void channelActive(ChannelHandlerContext ctx) {
|
||||||
|
String hostAddress = "null";
|
||||||
|
try {
|
||||||
|
hostAddress = ((InetSocketAddress) ctx.channel().remoteAddress()).getAddress().getHostAddress();
|
||||||
|
} catch (NullPointerException npe) {
|
||||||
|
log.warn("Unable to get remote address for client", npe);
|
||||||
|
}
|
||||||
|
this.hostAddress = hostAddress;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||||
// InPacket packet = new ByteBufInPacket((ByteBuf) msg);
|
// InPacket packet = new ByteBufInPacket((ByteBuf) msg);
|
||||||
@@ -191,6 +206,14 @@ public class MapleClient extends ChannelInboundHandlerAdapter {
|
|||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getHostAddress() {
|
||||||
|
return hostAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInTransition() {
|
||||||
|
return inTransition;
|
||||||
|
}
|
||||||
|
|
||||||
public EventManager getEventManager(String event) {
|
public EventManager getEventManager(String event) {
|
||||||
return getChannelServer().getEventSM().getEventManager(event);
|
return getChannelServer().getEventSM().getEventManager(event);
|
||||||
}
|
}
|
||||||
@@ -997,7 +1020,7 @@ public class MapleClient extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
public void setCharacterOnSessionTransitionState(int cid) {
|
public void setCharacterOnSessionTransitionState(int cid) {
|
||||||
this.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION);
|
this.updateLoginState(MapleClient.LOGIN_SERVER_TRANSITION);
|
||||||
session.setAttribute(MapleClient.CLIENT_TRANSITION);
|
this.inTransition = true;
|
||||||
Server.getInstance().setCharacteridInTransition(this, cid);
|
Server.getInstance().setCharacteridInTransition(this, cid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ public class MapleServerHandler extends IoHandlerAdapter {
|
|||||||
if (client != null) {
|
if (client != null) {
|
||||||
try {
|
try {
|
||||||
// client freeze issues on session transition states found thanks to yolinlin, Omo Oppa, Nozphex
|
// client freeze issues on session transition states found thanks to yolinlin, Omo Oppa, Nozphex
|
||||||
if (!session.containsAttribute(MapleClient.CLIENT_TRANSITION)) {
|
if (!client.isInTransition()) {
|
||||||
client.disconnect(false, false);
|
client.disconnect(false, false);
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
|
|||||||
Reference in New Issue
Block a user