Move some remaining bits and pieces to netty implementation, start cleaning up

This commit is contained in:
P0nk
2021-07-13 21:54:07 +02:00
parent fc694f1b0f
commit 94e1125eca
8 changed files with 64 additions and 389 deletions

View File

@@ -3,6 +3,8 @@ package net.netty;
import client.MapleClient;
import io.netty.channel.socket.SocketChannel;
import net.PacketProcessor;
import net.server.Server;
import net.server.coordinator.session.MapleSessionCoordinator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -20,12 +22,18 @@ public class ChannelServerInitializer extends ServerChannelInitializer {
@Override
public void initChannel(SocketChannel socketChannel) {
final String clientIp = socketChannel.remoteAddress().getHostName();
log.debug("Client connected to world {}, channel {} from {}", world, channel, clientIp);
log.debug("Client connecting to world {}, channel {} from {}", world, channel, clientIp);
PacketProcessor packetProcessor = PacketProcessor.getChannelServerProcessor(world, channel);
final MapleClient client = new MapleClient(packetProcessor, world, channel);
final MapleClient client = new MapleClient(MapleClient.Type.CHANNEL, packetProcessor, world, channel);
client.setSessionId(sessionId.getAndIncrement());
if (Server.getInstance().getChannel(world, channel) == null) {
MapleSessionCoordinator.getInstance().closeSession(client, true);
socketChannel.close();
return;
}
initPipeline(socketChannel, client);
}
}

View File

@@ -3,6 +3,7 @@ package net.netty;
import client.MapleClient;
import io.netty.channel.socket.SocketChannel;
import net.PacketProcessor;
import net.server.coordinator.session.MapleSessionCoordinator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -15,9 +16,14 @@ public class LoginServerInitializer extends ServerChannelInitializer {
log.debug("Client connected to login server from {} ", clientIp);
PacketProcessor packetProcessor = PacketProcessor.getLoginServerProcessor();
final MapleClient client = new MapleClient(packetProcessor, LoginServer.WORLD_ID, LoginServer.CHANNEL_ID);
final MapleClient client = new MapleClient(MapleClient.Type.LOGIN, packetProcessor, LoginServer.WORLD_ID, LoginServer.CHANNEL_ID);
client.setSessionId(sessionId.getAndIncrement());
if (!MapleSessionCoordinator.getInstance().canStartLoginSession(client)) {
socketChannel.close();
return;
}
initPipeline(socketChannel, client);
}
}