Minor renaming and refactoring

This commit is contained in:
P0nk
2021-06-29 20:27:32 +02:00
parent 828c3c5345
commit 0e98abff41
5 changed files with 329 additions and 306 deletions

View File

@@ -16,7 +16,16 @@ public abstract class ServerChannelInitializer extends ChannelInitializer<Socket
void initPipeline(SocketChannel socketChannel, MapleClient client) {
final InitializationVector sendIv = InitializationVector.generateSend();
final InitializationVector recvIv = InitializationVector.generateReceive();
writeInitialUnencryptedHelloPacket(socketChannel, sendIv, recvIv);
setUpHandlers(socketChannel, 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,
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);