Add client disconnection logic to TransitionService

Problem: disconnecting requires access to CharacterSaver,
which is not available in Client.
Having it in a service like this solves that problem.

Next step is to migrate all calls to Client#disconnect and Client#forceDisconnect
to their TransitionService counterparts.
This commit is contained in:
P0nk
2023-08-08 21:51:12 +02:00
parent f6d06ba82a
commit d5682a5f65
10 changed files with 272 additions and 102 deletions

View File

@@ -76,8 +76,8 @@ import server.expeditions.ExpeditionBossLog;
import server.life.PlayerNPCFactory;
import server.quest.Quest;
import server.shop.ShopFactory;
import service.ChannelService;
import service.NoteService;
import service.TransitionService;
import tools.DatabaseConnection;
import tools.Pair;
@@ -982,17 +982,17 @@ public class Server {
MonsterCardDao monsterCardDao = new MonsterCardDao(connection);
CharacterLoader characterLoader = new CharacterLoader(monsterCardDao);
CharacterSaver characterSaver = new CharacterSaver(monsterCardDao);
ChannelService channelService = new ChannelService(characterSaver);
TransitionService transitionService = new TransitionService(characterSaver);
NoteService noteService = new NoteService(new NoteDao(connection));
MakerProcessor makerProcessor = new MakerProcessor(new MakerInfoProvider(new MakerDao(connection)));
FredrickProcessor fredrickProcessor = new FredrickProcessor(noteService);
DropProvider dropProvider = new DropProvider(new DropDao(connection));
ShopFactory shopFactory = new ShopFactory(new ShopDao(connection));
CommandContext commandContext = new CommandContext(null, dropProvider, shopFactory,
characterSaver, channelService);
characterSaver, transitionService);
CommandsExecutor commandsExecutor = new CommandsExecutor(commandContext);
ChannelDependencies channelDependencies = new ChannelDependencies(characterLoader, characterSaver, noteService,
fredrickProcessor, makerProcessor, dropProvider, commandsExecutor, shopFactory, channelService);
fredrickProcessor, makerProcessor, dropProvider, commandsExecutor, shopFactory, transitionService);
PacketProcessor.registerGameHandlerDependencies(channelDependencies);

View File

@@ -27,16 +27,16 @@ import net.AbstractPacketHandler;
import net.netty.GameViolationException;
import net.packet.InPacket;
import net.server.Server;
import service.ChannelService;
import service.TransitionService;
/**
* @author Matze
*/
public final class ChangeChannelHandler extends AbstractPacketHandler {
private final ChannelService channelService;
private final TransitionService transitionService;
public ChangeChannelHandler(ChannelService channelService) {
this.channelService = channelService;
public ChangeChannelHandler(TransitionService transitionService) {
this.transitionService = transitionService;
}
@Override
@@ -51,6 +51,6 @@ public final class ChangeChannelHandler extends AbstractPacketHandler {
return;
}
channelService.changeChannel(c, channel);
transitionService.changeChannel(c, channel);
}
}