Internal dispatch works!

This commit is contained in:
Brandon Thomas
2021-02-16 02:01:48 -05:00
parent 3cd0c98f7a
commit 57454c768a
2 changed files with 30 additions and 6 deletions
@@ -63,11 +63,11 @@ void AEventSourceActor::Tick(float DeltaTime)
void AEventSourceActor::ConstructClient()
{
if (redis != nullptr) {
UE_LOG(EventSourceLog, Log, TEXT("Construct2(): Redis is NOT null"));
UE_LOG(EventSourceLog, Log, TEXT("Construct(): Redis is NOT null"));
return;
}
UE_LOG(EventSourceLog, Log, TEXT("construct2(): redis = new Redis()"));
UE_LOG(EventSourceLog, Log, TEXT("construct(): redis = new Redis()"));
redis = NewObject<URedisObject>(this, TEXT("RedisObject"));
}
@@ -75,28 +75,47 @@ void AEventSourceActor::ConstructClient()
void AEventSourceActor::Init()
{
if (redis == nullptr) {
UE_LOG(EventSourceLog, Log, TEXT("Init2(): Redis is null"));
UE_LOG(EventSourceLog, Log, TEXT("Init(): Redis is null"));
return;
}
//UE_LOG(EventSourceLog, Log, TEXT("construct(): redis = new Redis()"));
//redis = NewObject<URedisObject>(this, TEXT("RedisObject"));
UE_LOG(EventSourceLog, Log, TEXT("Init2(): redis->Init()"));
UE_LOG(EventSourceLog, Log, TEXT("Init(): redis->Init()"));
redis->Init(redisHost, redisPort, redisPassword);
}
void AEventSourceActor::Subscribe(const FString& Channel)
{
if (redis == nullptr) {
UE_LOG(EventSourceLog, Log, TEXT("Subscribe2(): Redis is null"));
UE_LOG(EventSourceLog, Log, TEXT("Subscribe(): Redis is null"));
return;
}
UE_LOG(EventSourceLog, Log, TEXT("Subscribe2(): redis->Subscribe()"));
UE_LOG(EventSourceLog, Log, TEXT("Subscribe(): redis->Subscribe()"));
redis->Subscribe(Channel);
if (!redis->SubscribeReply.IsBound()) {
UE_LOG(EventSourceLog, Log, TEXT("Subscribe(): binding event"));
//redis->SubscribeReply.AddDynamic(this, "AEventSourceActor::SubscribeCallback(FString Channel, FString Message)");
redis->SubscribeReply.AddDynamic(this, &AEventSourceActor::SubscribeCallback);
}
}
void AEventSourceActor::Unsubscribe(const FString& Channel)
{
if (redis == nullptr) {
UE_LOG(EventSourceLog, Log, TEXT("Unsubscribe(): Redis is null"));
return;
}
UE_LOG(EventSourceLog, Log, TEXT("Unsubscribe(): redis->Unsubscribe()"));
redis->Unsubscribe(Channel);
}
void AEventSourceActor::SubscribeCallback(FString Channel, FString Message)
{
//UE_LOG(EventSourceLog, Log, TEXT("SubscribeCallback(): %s %s"), Channel, Message);
UE_LOG(EventSourceLog, Log, TEXT("SubscribeCallback(): called"));
}
@@ -71,6 +71,11 @@ protected:
private:
URedisObject* redis;
// Handle callbacks.
// NB(bt): Declared 'UFUNCTION()' so reflection enables as a delegate callback.
UFUNCTION()
void SubscribeCallback(FString Channel, FString Message);
public:
// Called every frame
virtual void Tick(float DeltaTime) override;