-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Message_Close handler, reboot event notifier, and reboot sound effect id
- Loading branch information
Showing
4 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using AutomaticTypeMapper; | ||
|
||
namespace EOLib.Domain.Notifiers | ||
{ | ||
public interface IServerRebootNotifier | ||
{ | ||
void NotifyServerReboot(); | ||
} | ||
|
||
[AutoMappedType] | ||
public class NoOpServerRebootNotifier : IServerRebootNotifier | ||
{ | ||
public void NotifyServerReboot() { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
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.Message | ||
{ | ||
/// <summary> | ||
/// Shows the server reboot message | ||
/// </summary> | ||
[AutoMappedType] | ||
public class MessageCloseHandler : InGameOnlyPacketHandler<MessageCloseServerPacket> | ||
{ | ||
private readonly IEnumerable<IServerRebootNotifier> _serverRebootNotifiers; | ||
|
||
public override PacketFamily Family => PacketFamily.Message; | ||
|
||
public override PacketAction Action => PacketAction.Close; | ||
|
||
public MessageCloseHandler(IPlayerInfoProvider playerInfoProvider, | ||
IEnumerable<IServerRebootNotifier> serverRebootNotifiers) | ||
: base(playerInfoProvider) | ||
{ | ||
_serverRebootNotifiers = serverRebootNotifiers; | ||
} | ||
|
||
|
||
public override bool HandlePacket(MessageCloseServerPacket packet) | ||
{ | ||
foreach (var notifier in _serverRebootNotifiers) | ||
notifier.NotifyServerReboot(); | ||
|
||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using AutomaticTypeMapper; | ||
using EndlessClient.Audio; | ||
using EndlessClient.HUD; | ||
using EndlessClient.HUD.Chat; | ||
using EOLib.Domain.Notifiers; | ||
using EOLib.Localization; | ||
|
||
namespace EndlessClient.Subscribers | ||
{ | ||
[AutoMappedType] | ||
public class ServerRebootEventNotifier : IServerRebootNotifier | ||
{ | ||
private readonly ILocalizedStringFinder _localizedStringFinder; | ||
private readonly IServerMessageHandler _serverMessageHandler; | ||
private readonly IStatusLabelSetter _statusLabelSetter; | ||
|
||
public ServerRebootEventNotifier(ILocalizedStringFinder localizedStringFinder, | ||
IServerMessageHandler serverMessageHandler, | ||
IStatusLabelSetter statusLabelSetter, | ||
ISfxPlayer sfxPlayer) | ||
{ | ||
_localizedStringFinder = localizedStringFinder; | ||
_serverMessageHandler = serverMessageHandler; | ||
_statusLabelSetter = statusLabelSetter; | ||
} | ||
|
||
public void NotifyServerReboot() | ||
{ | ||
var message = _localizedStringFinder.GetString(EOResourceID.REBOOT_SEQUENCE_STARTED); | ||
_serverMessageHandler.AddServerMessage(message, SoundEffectID.Reboot); | ||
_statusLabelSetter.ShowWarning(message); | ||
} | ||
} | ||
} |