Skip to content

Commit

Permalink
Rename InternalCommandDeduplicateEvents to LuaManagerCommandDeduplica…
Browse files Browse the repository at this point in the history
…teEvents
  • Loading branch information
dennis committed Jan 10, 2021
1 parent b629ae2 commit 0ff2b96
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 17 deletions.
6 changes: 3 additions & 3 deletions Backend/Plugins/LuaManagerPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Slipstream.Backend.Services;
using Slipstream.Shared;
using Slipstream.Shared.Events.Internal;
using Slipstream.Shared.Events.LuaManager;
using System;
using System.Collections.Generic;
using System.IO;
Expand Down Expand Up @@ -44,14 +44,14 @@ public LuaManagerPlugin(string id, IEventFactory eventFactory, IEventBus eventBu
EventHandler.OnFileMonitorFileRenamed += EventHandler_OnFileMonitorFileRenamed;
EventHandler.OnFileMonitorScanCompleted += EventHandler_OnFileMonitorScanCompleted;
EventHandler.OnInternalPluginState += EventHandler_OnInternalPluginState;
EventHandler.OnInternalCommandDeduplicateEvents += (s, e) => EventHandler_OnInternalCommandDeduplicateEvents(e.Event);
EventHandler.OnLuaManagerCommandDeduplicateEvents += (s, e) => EventHandler_OnInternalCommandDeduplicateEvents(e.Event);

BootupEventsDeadline = DateTime.Now.AddMilliseconds(500);

EventBus.PublishEvent(EventFactory.CreateFileMonitorCommandScan());
}

private void EventHandler_OnInternalCommandDeduplicateEvents(InternalCommandDeduplicateEvents @event)
private void EventHandler_OnInternalCommandDeduplicateEvents(LuaManagerCommandDeduplicateEvents @event)
{
foreach (var e in EventSerdeService.DeserializeMultiple(@event.Events))
{
Expand Down
2 changes: 1 addition & 1 deletion Backend/Plugins/LuaPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private void StartLua()
var eventsCaptured = EventBus.CapturedEvents;
EventBus.StopCapturing();

EventBus.PublishEvent(EventFactory.CreateInternalCommandDeduplicateEvents(eventsCaptured));
EventBus.PublishEvent(EventFactory.CreateLuaManagerCommandDeduplicateEvents(eventsCaptured));
}

private void HandleLuaException(LuaException e)
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
- UICommandWriteToConsole is now UIMethodCollection
- InternalReconfigured is now InternalCommandReconfigure
- InternalBootupEvents is now InternalCommandDeduplicateEvents
- InternalCommandDeduplicateEvents is now LuaManagerCommandDeduplicateEvents
- Plugin renamed: FileTriggerPlugin to LuaManagerPlugin
- UI: Stores/restores Window position and size
- Event: Adds TwitchReceivedMessage event (captures all messages, not only commands)
- Event: Removes TwitchReceivedCommand event as this is already sent as a TwitchReceivedMessage
Expand Down
5 changes: 3 additions & 2 deletions Shared/EventFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Slipstream.Shared.Events.FileMonitor;
using Slipstream.Shared.Events.Internal;
using Slipstream.Shared.Events.IRacing;
using Slipstream.Shared.Events.LuaManager;
using Slipstream.Shared.Events.Twitch;
using Slipstream.Shared.Events.UI;
using System;
Expand Down Expand Up @@ -75,7 +76,7 @@ public InternalCommandReconfigure CreateInternalCommandReconfigure()
return new InternalCommandReconfigure();
}

public InternalCommandDeduplicateEvents CreateInternalCommandDeduplicateEvents(IEvent[] events)
public LuaManagerCommandDeduplicateEvents CreateLuaManagerCommandDeduplicateEvents(IEvent[] events)
{
string json = "";

Expand All @@ -84,7 +85,7 @@ public InternalCommandDeduplicateEvents CreateInternalCommandDeduplicateEvents(I
json += EventSerdeService.Serialize(e) + "\n";
}

return new InternalCommandDeduplicateEvents
return new LuaManagerCommandDeduplicateEvents
{
Events = json
};
Expand Down
15 changes: 10 additions & 5 deletions Shared/EventHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ public EventHandlerArgs(T e)

public delegate void OnInternalCommandReconfigureHandler(EventHandler source, EventHandlerArgs<Shared.Events.Internal.InternalCommandReconfigure> e);
public event OnInternalCommandReconfigureHandler? OnInternalCommandReconfigure;
#endregion

public delegate void OnInternalCommandDeduplicateEventsHandler(EventHandler source, EventHandlerArgs<Shared.Events.Internal.InternalCommandDeduplicateEvents> e);
public event OnInternalCommandDeduplicateEventsHandler? OnInternalCommandDeduplicateEvents;
#region Events: LuaManager
public delegate void OnInternalCommandDeduplicateEventsHandler(EventHandler source, EventHandlerArgs<Shared.Events.LuaManager.LuaManagerCommandDeduplicateEvents> e);
public event OnInternalCommandDeduplicateEventsHandler? OnLuaManagerCommandDeduplicateEvents;

#endregion

Expand Down Expand Up @@ -207,11 +209,14 @@ public void HandleEvent(IEvent? ev)
else
OnInternalCommandReconfigure.Invoke(this, new EventHandlerArgs<Shared.Events.Internal.InternalCommandReconfigure>(tev));
break;
case Shared.Events.Internal.InternalCommandDeduplicateEvents tev:
if (OnInternalCommandDeduplicateEvents == null)

// LuaManager

case Shared.Events.LuaManager.LuaManagerCommandDeduplicateEvents tev:
if (OnLuaManagerCommandDeduplicateEvents == null)
OnDefault?.Invoke(this, new EventHandlerArgs<IEvent>(tev));
else
OnInternalCommandDeduplicateEvents.Invoke(this, new EventHandlerArgs<Shared.Events.Internal.InternalCommandDeduplicateEvents>(tev));
OnLuaManagerCommandDeduplicateEvents.Invoke(this, new EventHandlerArgs<Shared.Events.LuaManager.LuaManagerCommandDeduplicateEvents>(tev));
break;

// File Monitor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using System.Collections.Generic;

namespace Slipstream.Shared.Events.Internal
namespace Slipstream.Shared.Events.LuaManager
{
public class InternalCommandDeduplicateEvents : IEvent
public class LuaManagerCommandDeduplicateEvents : IEvent
{
public string EventType => "InternalCommandDeduplicateEvents";
public string EventType => "LuaManagerCommandDeduplicateEvents";

public bool ExcludeFromTxrx => true;

public string Events { get; set; } = "";

public override bool Equals(object obj)
{
return obj is InternalCommandDeduplicateEvents events &&
return obj is LuaManagerCommandDeduplicateEvents events &&
EventType == events.EventType &&
ExcludeFromTxrx == events.ExcludeFromTxrx &&
Events == events.Events;
Expand Down
3 changes: 2 additions & 1 deletion Shared/IEventFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Slipstream.Shared.Events.FileMonitor;
using Slipstream.Shared.Events.Internal;
using Slipstream.Shared.Events.IRacing;
using Slipstream.Shared.Events.LuaManager;
using Slipstream.Shared.Events.Twitch;
using Slipstream.Shared.Events.UI;

Expand Down Expand Up @@ -39,7 +40,7 @@ public enum IRacingSessionStateEnum
InternalCommandPluginUnregister CreateInternalCommandPluginUnregister(string pluginId);
InternalPluginState CreateInternalPluginState(string pluginId, string pluginName, string displayName, PluginStatusEnum pluginStatus);
InternalCommandReconfigure CreateInternalCommandReconfigure();
InternalCommandDeduplicateEvents CreateInternalCommandDeduplicateEvents(IEvent[] events);
LuaManagerCommandDeduplicateEvents CreateLuaManagerCommandDeduplicateEvents(IEvent[] events);

IRacingCarCompletedLap CreateIRacingCarCompletedLap(double sessionTime, long carIdx, double time, int lapsCompleted, float? fuelDiff, bool localUser);
IRacingCarInfo CreateIRacingCarInfo(
Expand Down
2 changes: 1 addition & 1 deletion Slipstream.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
<Compile Include="Shared\EventFactory.cs" />
<Compile Include="Shared\Events\FileMonitor\FileMonitorCommandScan.cs" />
<Compile Include="Shared\Events\FileMonitor\FileMonitorScanCompleted.cs" />
<Compile Include="Shared\Events\Internal\InternalCommandDeduplicateEvents.cs" />
<Compile Include="Shared\Events\LuaManager\LuaManagerCommandDeduplicateEvents.cs" />
<Compile Include="Shared\Events\Internal\InternalCommandReconfigure.cs" />
<Compile Include="Shared\Events\Internal\InternalCommandPluginStates.cs" />
<Compile Include="Shared\Events\IRacing\IRacingCommandSendTrackInfo.cs" />
Expand Down

0 comments on commit 0ff2b96

Please sign in to comment.