Hi,
Goal - Implementing Http functionalities in an normal cpp class(not an Actor) and access those functionalities from an Actor class.
i.e : TestHttp.cpp(Normal Class) SCRIPT:1
void ApiManager::Login(FString userName, FString password)
{
fHttpModule = &FHttpModule::Get();
Variables* VariableClass = new Variables();
FString url = VariableClass->BaseApiURL() +VariableClass->ApiSignin();
TSharedPtr<FJsonObject> session = CreateJson(userName, password);
FString OutputString;
TSharedRef< TJsonWriter<> > Writer = TJsonWriterFactory<>::Create(&OutputString);
FJsonSerializer::Serialize(session.ToSharedRef(), Writer);
TSharedRef<IHttpRequest*> Request = fHttpModule->CreateRequestPtr();
Request.Get()->SetURL(url);
Request.Get()->SetVerb("POST");
Request.Get()->SetContentAsString(OutputString);
Request.Get()->SetHeader(tapVariableClass->HeadContent(),VariableClass->HeadContentValue());
Request.Get()->OnProcessRequestComplete().BindRaw(this, &ApiManager::LoginResponse);
Send(Request);
}
CallFunction.cpp(Actor Class) SCRIPT:2
void ACallFunction::BeginPlay()
{
Super::BeginPlay();
ApiManager* tpm = new ApiManager();
tpm->Login("abcd", "apple");
}
if the login function being accessed from an actor class unreal crashes
and it throws an error at -> TSharedRef<IHttpRequest*> Request = fHttpModule->CreateRequestPtr();
But the same works fine when the HTTP functionalities were created in an Actor class and called from the same Actor class.
did anyone faced similar issue ?