mirror of
https://github.com/storytold/EventCenterPlugin.git
synced 2026-10-09 00:09:42 +00:00
Internal dispatch works!
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user