Files
TurboLinkTest/Client/Source/TurboLinkTest/TurboLinkTestController.h
T

150 lines
3.4 KiB
C++

// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "SGreeter/HelloService.h"
#include "TurboLinkTestController.generated.h"
class UTimeTestDSWidget;
/**
*
*/
UCLASS()
class TURBOLINKTEST_API ATurboLinkTestController : public APlayerController
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Server, Reliable)
void ConnectToTimeService();
UFUNCTION(BlueprintCallable, Server, Reliable)
void ShutdownTimeService();
UFUNCTION(BlueprintCallable, Server, Reliable)
void CreateTimeClient();
UFUNCTION(BlueprintCallable, Server, Reliable)
void ShutdownTimeClient();
UFUNCTION(BlueprintCallable, Server, Reliable)
void CallTimeNow();
UFUNCTION(BlueprintCallable, Server, Reliable)
void CancelTimeNow();
UFUNCTION(BlueprintCallable, Server, Reliable)
void CallTimeTicktok(int32 Counts);
UFUNCTION(BlueprintCallable, Server, Reliable)
void CancelTimeTicktok();
UFUNCTION(BlueprintCallable, Server, Reliable)
void InitTimeWatch();
UFUNCTION(BlueprintCallable, Server, Reliable)
void CallTimeWatch();
UFUNCTION(BlueprintCallable, Server, Reliable)
void CancelTimeWatch();
protected:
UPROPERTY(BlueprintReadOnly)
UTimeService* TimeService;
UFUNCTION()
void OnTimeServiceStateChanged(EGrpcServiceState NewState);
UPROPERTY(BlueprintReadOnly)
UTimeServiceClient* TimeServiceClient;
UFUNCTION()
void OnContextStateChange(FGrpcContextHandle Handle, EGrpcContextState State);
FGrpcContextHandle CtxNow;
UFUNCTION()
void OnTimeNowResponse(FGrpcContextHandle Handle, const FGrpcResult& Result, const FGrpcGreeterNowResponse& Response);
FGrpcContextHandle CtxTicktok;
UFUNCTION()
void OnTimeTicktokResponse(FGrpcContextHandle Handle, const FGrpcResult& Result, const FGrpcGreeterNowResponse& Response);
FGrpcContextHandle CtxWatch;
UFUNCTION()
void OnTimeWatchResponse(FGrpcContextHandle Handle, const FGrpcResult& Result, const FGrpcGreeterNowResponse& Response);
public:
EGrpcServiceState GetTimeServiceState() const {
return TimeServiceState;
}
bool IsClientCreated() const {
return bIsClientCreated;
}
EGrpcContextState GetCtxNowState() const {
return CtxNowState;
}
EGrpcContextState GetCtxTicktokState() const {
return CtxTicktokState;
}
EGrpcContextState GetCtxWatchState() const {
return CtxWatchState;
}
UPROPERTY(BlueprintReadOnly)
UTimeTestDSWidget* ClientWidget;
protected:
UPROPERTY(ReplicatedUsing = OnRep_TimeServiceState)
EGrpcServiceState TimeServiceState;
UFUNCTION()
void OnRep_TimeServiceState();
UPROPERTY(ReplicatedUsing = OnRep_ClientCreated)
bool bIsClientCreated = false;
UFUNCTION()
void OnRep_ClientCreated();
protected:
UFUNCTION()
void OnRep_TimeContextState();
UPROPERTY(ReplicatedUsing = OnRep_TimeContextState)
EGrpcContextState CtxNowState = EGrpcContextState::Done;
UPROPERTY(ReplicatedUsing = OnRep_TimeContextState)
EGrpcContextState CtxTicktokState = EGrpcContextState::Done;
UPROPERTY(ReplicatedUsing = OnRep_TimeContextState)
EGrpcContextState CtxWatchState = EGrpcContextState::Done;
UPROPERTY(ReplicatedUsing = OnRep_TimeNowResult)
FString NowResult;
UFUNCTION()
void OnRep_TimeNowResult();
UPROPERTY(ReplicatedUsing = OnRep_TimeTicktokResult)
FString TicktokResult;
UFUNCTION()
void OnRep_TimeTicktokResult();
UPROPERTY(ReplicatedUsing = OnRep_TimeWatchResult)
FString WatchResult;
UFUNCTION()
void OnRep_TimeWatchResult();
};