-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(push-events): data not synchronising on second instance startup (#…
…400) * fix(push-events): data not synchronising on second instance startup Until now, some push events (stands etc) were not syncing up when a second instance of EuroScope was started. This fixes the synchronisation. Fix #399 * Tidy CMake
- Loading branch information
Showing
7 changed files
with
100 additions
and
4 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
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,21 @@ | ||
#include "ProxyPushDataSync.h" | ||
#include "PushEventProcessorCollection.h" | ||
|
||
namespace UKControllerPlugin::Push { | ||
|
||
ProxyPushDataSync::ProxyPushDataSync(const PushEventProcessorCollection& processors) | ||
: processors(processors), synced(false) | ||
{ | ||
} | ||
|
||
void ProxyPushDataSync::TimedEventTrigger() | ||
{ | ||
if (synced) { | ||
return; | ||
} | ||
|
||
LogInfo("Syncing proxy push event data"); | ||
processors.PluginEventsSynced(); | ||
synced = true; | ||
} | ||
} // namespace UKControllerPlugin::Push |
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,25 @@ | ||
#pragma once | ||
#include "timedevent/AbstractTimedEvent.h" | ||
|
||
namespace UKControllerPlugin::Push { | ||
class PushEventProcessorCollection; | ||
|
||
/* | ||
* When proxy connections are created, we need to make sure their data is synced (more or less) | ||
* with the API. This handler triggers on a timer once ES is loaded (so we know all the handlers are registered) | ||
* and triggers their synced event. | ||
*/ | ||
class ProxyPushDataSync : public TimedEvent::AbstractTimedEvent | ||
{ | ||
public: | ||
ProxyPushDataSync(const PushEventProcessorCollection& processors); | ||
void TimedEventTrigger() override; | ||
|
||
private: | ||
// All the push event processors | ||
const PushEventProcessorCollection& processors; | ||
|
||
// Has the sync been done | ||
bool synced; | ||
}; | ||
} // namespace UKControllerPlugin::Push |
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
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,41 @@ | ||
#include "push/ProxyPushDataSync.h" | ||
#include "push/PushEventProcessorCollection.h" | ||
#include "push/PushEventSubscription.h" | ||
|
||
using testing::NiceMock; | ||
using testing::Test; | ||
using UKControllerPlugin::Push::ProxyPushDataSync; | ||
using UKControllerPlugin::Push::PushEventProcessorCollection; | ||
using UKControllerPlugin::Push::PushEventSubscription; | ||
|
||
namespace UKControllerPluginTest::Push { | ||
|
||
class ProxyPushDataSyncTest : public Test | ||
{ | ||
public: | ||
ProxyPushDataSyncTest() : eventProcessor(std::make_shared<NiceMock<MockPushEventProcessor>>()), sync(collection) | ||
{ | ||
this->collection.AddProcessor(this->eventProcessor); | ||
} | ||
|
||
PushEventProcessorCollection collection; | ||
std::shared_ptr<NiceMock<MockPushEventProcessor>> eventProcessor; | ||
ProxyPushDataSync sync; | ||
}; | ||
|
||
TEST_F(ProxyPushDataSyncTest, ItSyncsProxyDataOnFirstTimedEvent) | ||
{ | ||
EXPECT_CALL(*this->eventProcessor, PluginEventsSynced).Times(1); | ||
|
||
sync.TimedEventTrigger(); | ||
} | ||
|
||
TEST_F(ProxyPushDataSyncTest, ItDoesntSyncOnSubsequentTimedEvents) | ||
{ | ||
EXPECT_CALL(*this->eventProcessor, PluginEventsSynced).Times(1); | ||
|
||
sync.TimedEventTrigger(); | ||
sync.TimedEventTrigger(); | ||
sync.TimedEventTrigger(); | ||
} | ||
} // namespace UKControllerPluginTest::Push |
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