Skip to content

Commit

Permalink
Implement JUKEBOX_REPLY handler
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed Jun 1, 2024
1 parent 55ada61 commit 01a00d1
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 2 deletions.
2 changes: 0 additions & 2 deletions EOLib/Domain/Interact/Jukebox/JukeboxActions.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using AutomaticTypeMapper;
using EOLib.Domain.Character;
using EOLib.Domain.Map;
using EOLib.IO;
using EOLib.IO.Repositories;
using EOLib.Net;
using EOLib.Net.Communication;
using Moffat.EndlessOnline.SDK.Protocol.Net.Client;
using Optional.Collections;
Expand Down
16 changes: 16 additions & 0 deletions EOLib/Domain/Notifiers/IJukeboxNotifier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using AutomaticTypeMapper;

namespace EOLib.Domain.Notifiers
{
public interface IJukeboxNotifier
{
void JukeboxUnavailable();
}

[AutoMappedType]
public class NoOpJukeboxNotifier : IJukeboxNotifier
{
public void JukeboxUnavailable() { }
}

}
34 changes: 34 additions & 0 deletions EOLib/PacketHandlers/Jukebox/JukeboxReplyHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using AutomaticTypeMapper;
using EOLib.Domain.Login;
using EOLib.Domain.Notifiers;
using EOLib.Net.Handlers;
using Moffat.EndlessOnline.SDK.Protocol.Net;
using Moffat.EndlessOnline.SDK.Protocol.Net.Server;
using System.Collections.Generic;

namespace EOLib.PacketHandlers.Jukebox
{
[AutoMappedType]
public class JukeboxReplyHandler : InGameOnlyPacketHandler<JukeboxReplyServerPacket>
{
private readonly IEnumerable<IJukeboxNotifier> _jukeboxNotifiers;

public override PacketFamily Family => PacketFamily.Jukebox;

public override PacketAction Action => PacketAction.Reply;

public JukeboxReplyHandler(IPlayerInfoProvider playerInfoProvider,
IEnumerable<IJukeboxNotifier> jukeboxNotifiers)
: base(playerInfoProvider)
{
_jukeboxNotifiers = jukeboxNotifiers;
}

public override bool HandlePacket(JukeboxReplyServerPacket packet)
{
foreach (var notifier in _jukeboxNotifiers)
notifier.JukeboxUnavailable();
return true;
}
}
}
24 changes: 24 additions & 0 deletions EndlessClient/Subscribers/JukeboxEventSubscriber.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using AutomaticTypeMapper;
using EndlessClient.Dialogs.Factories;
using EOLib.Domain.Notifiers;
using EOLib.Localization;

namespace EndlessClient.Subscribers
{
[AutoMappedType]
public class JukeboxEventSubscriber : IJukeboxNotifier
{
private readonly IEOMessageBoxFactory _messageBoxFactory;

public JukeboxEventSubscriber(IEOMessageBoxFactory messageBoxFactory)
{
_messageBoxFactory = messageBoxFactory;
}

public void JukeboxUnavailable()
{
var dlg = _messageBoxFactory.CreateMessageBox(DialogResourceID.JUKEBOX_REQUESTED_RECENTLY);
dlg.ShowDialog();
}
}
}

0 comments on commit 01a00d1

Please sign in to comment.