mirror of
https://github.com/storytold/EventCenterPlugin.git
synced 2026-10-09 00:09:42 +00:00
Can't reconnect to Redis, and it randomly dies... ugh
The pattern of unsubscribe/subscribe seems to segfault, as do reconnect, etc. This Redis plugin isn't durable.
This commit is contained in:
@@ -34,6 +34,7 @@ void AEventSourceActor::BeginPlay()
|
|||||||
{
|
{
|
||||||
Super::BeginPlay();
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, "BeginPlay() - 2");
|
||||||
UE_LOG(EventSourceLog, Log, TEXT("BeginPlay()"));
|
UE_LOG(EventSourceLog, Log, TEXT("BeginPlay()"));
|
||||||
|
|
||||||
if (redis == nullptr) {
|
if (redis == nullptr) {
|
||||||
@@ -56,6 +57,16 @@ void AEventSourceActor::Tick(float DeltaTime)
|
|||||||
{
|
{
|
||||||
Super::Tick(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
|
// NB: Handled by RedisObject internal delegate
|
||||||
//redis->Tick(DeltaTime);
|
//redis->Tick(DeltaTime);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,6 +77,9 @@ private:
|
|||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void InternalSubscribeCallback(FString Channel, FString Message);
|
void InternalSubscribeCallback(FString Channel, FString Message);
|
||||||
|
|
||||||
|
// For a timer calculation.
|
||||||
|
float timerLastTime = 0.0f;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Called every frame
|
// Called every frame
|
||||||
virtual void Tick(float DeltaTime) override;
|
virtual void Tick(float DeltaTime) override;
|
||||||
|
|||||||
Reference in New Issue
Block a user