diff --git a/Source/EventCenterPlugin/Private/EventSourceActor.cpp b/Source/EventCenterPlugin/Private/EventSourceActor.cpp index e30017c..c47f8f2 100644 --- a/Source/EventCenterPlugin/Private/EventSourceActor.cpp +++ b/Source/EventCenterPlugin/Private/EventSourceActor.cpp @@ -34,6 +34,7 @@ void AEventSourceActor::BeginPlay() { Super::BeginPlay(); + GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, "BeginPlay() - 2"); UE_LOG(EventSourceLog, Log, TEXT("BeginPlay()")); if (redis == nullptr) { @@ -55,6 +56,16 @@ void AEventSourceActor::BeginDestroy() void AEventSourceActor::Tick(float DeltaTime) { Super::Tick(DeltaTime); + + float time = GetGameTimeSinceCreation(); + + if (time - timerLastTime > 15.0) { + timerLastTime = time; + GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, "seconds elapsed"); + redis->Unsubscribe(TEXT("second")); + redis->Subscribe(TEXT("second")); + } + // NB: Handled by RedisObject internal delegate //redis->Tick(DeltaTime); diff --git a/Source/EventCenterPlugin/Public/EventSourceActor.h b/Source/EventCenterPlugin/Public/EventSourceActor.h index 933c9c2..eb79d3b 100644 --- a/Source/EventCenterPlugin/Public/EventSourceActor.h +++ b/Source/EventCenterPlugin/Public/EventSourceActor.h @@ -77,6 +77,9 @@ private: UFUNCTION() void InternalSubscribeCallback(FString Channel, FString Message); + // For a timer calculation. + float timerLastTime = 0.0f; + public: // Called every frame virtual void Tick(float DeltaTime) override;