Files
EventCenterPlugin/Source/EventCenterPlugin/Public/EventSourceActor.h
T

84 lines
2.0 KiB
C++

#pragma once
// Unreal Core
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
// RedisPlugin
#include "RedisObject.h"
// EventCenterPlugin
#include "EventSourceActor.generated.h"
DECLARE_LOG_CATEGORY_EXTERN(EventSourceLog, Log, All);
/**
* AEventSourceActor
*
* Manages an underlying Redis pubsub subscription and coordinates dispatch to other actors.
*/
// NB(bt): "Blueprintable" seems to remove the ability to add BP event nodes.
UCLASS()
class EVENTCENTERPLUGIN_API AEventSourceActor : public AActor
{
GENERATED_BODY()
public:
AEventSourceActor();
~AEventSourceActor();
/** Redis Hostname */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "EventCenter")
FString redisHost;
/** Redis Port */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "EventCenter")
int32 redisPort = 6379;
/** Redis Password */
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "EventCenter")
FString redisPassword;
/** Construct Redis Object.*/
UFUNCTION(BlueprintCallable, Category = "EventCenter")
void ConstructClient();
/** Connect to Redis.*/
UFUNCTION(BlueprintCallable, Category = "EventCenter")
void Init();
/** Subscribe to a named Redis PubSub channel. */
UFUNCTION(BlueprintCallable, Category = "EventCenter")
void Subscribe(const FString& Channel);
/** Unsubscribe from a named Redis PubSub channel. */
UFUNCTION(BlueprintCallable, Category = "EventCenter")
void Unsubscribe(const FString& Channel);
/** I have no idea what do... */
UPROPERTY(BlueprintAssignable)
FSubscribeReply SubscribeReplyy;
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
virtual void BeginDestroy() override;
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;
};