Minor refactors
This commit is contained in:
@@ -4,6 +4,7 @@ import client.MapleClient;
|
||||
import constants.net.ServerConstants;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelInitializer;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.socket.SocketChannel;
|
||||
import io.netty.handler.timeout.IdleStateHandler;
|
||||
import tools.MaplePacketCreator;
|
||||
@@ -17,17 +18,17 @@ public abstract class ServerChannelInitializer extends ChannelInitializer<Socket
|
||||
final InitializationVector sendIv = InitializationVector.generateSend();
|
||||
final InitializationVector recvIv = InitializationVector.generateReceive();
|
||||
writeInitialUnencryptedHelloPacket(socketChannel, sendIv, recvIv);
|
||||
setUpHandlers(socketChannel, sendIv, recvIv, client);
|
||||
setUpHandlers(socketChannel.pipeline(), sendIv, recvIv, client);
|
||||
}
|
||||
|
||||
private void writeInitialUnencryptedHelloPacket(SocketChannel socketChannel, InitializationVector sendIv, InitializationVector recvIv) {
|
||||
socketChannel.writeAndFlush(Unpooled.wrappedBuffer(MaplePacketCreator.getHello(ServerConstants.VERSION, sendIv, recvIv)));
|
||||
}
|
||||
|
||||
private void setUpHandlers(SocketChannel socketChannel, InitializationVector sendIv, InitializationVector recvIv,
|
||||
private void setUpHandlers(ChannelPipeline pipeline, InitializationVector sendIv, InitializationVector recvIv,
|
||||
MapleClient client) {
|
||||
socketChannel.pipeline().addFirst("IdleStateHandler", new IdleStateHandler(30, 30, 0));
|
||||
socketChannel.pipeline().addLast("PacketCodec", new PacketCodec(ClientCyphers.of(sendIv, recvIv)));
|
||||
socketChannel.pipeline().addLast("MapleClient", client);
|
||||
pipeline.addFirst("IdleStateHandler", new IdleStateHandler(30, 30, 0));
|
||||
pipeline.addLast("PacketCodec", new PacketCodec(ClientCyphers.of(sendIv, recvIv)));
|
||||
pipeline.addLast("MapleClient", client);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,14 +155,14 @@ public class MapleSessionCoordinator {
|
||||
return false;
|
||||
}
|
||||
|
||||
addRemoteHostSession(remoteHost, session);
|
||||
addLoginRemoteHostSession(remoteHost, session);
|
||||
return true;
|
||||
} finally {
|
||||
sessionInit.finalize(remoteHost);
|
||||
}
|
||||
}
|
||||
|
||||
private void addRemoteHostSession(String remoteHost, IoSession session) {
|
||||
private void addLoginRemoteHostSession(String remoteHost, IoSession session) {
|
||||
Set<IoSession> sessions = new HashSet<>(2);
|
||||
sessions.add(session);
|
||||
loginRemoteHosts.put(remoteHost, sessions);
|
||||
|
||||
Reference in New Issue
Block a user