void ATestProjectGameModeBase::HttpCall(const FString& InURL, const FString& InVerb)

{

TSharedRef<IHttpRequest> Request = Http->CreateRequest();

Request->OnProcessRequestComplete().BindUObject(this, &ATestProjectGameModeBase::OnResponseReceived);


//This is the url on which to process the request


Request->SetURL(InURL);

Request->SetVerb(InVerb);

Request->SetHeader("Content-Type", TEXT("application/json"));

TSharedRef<FJsonObject> RequestObj = MakeShared<FJsonObject>();

RequestObj->SetStringField("input", "obj");

RequestObj->SetStringField("voice", "obj");



FString RequestBody;

TSharedRef<TJsonWriter<>> Writer = TJsonWriterFactory<>::Create(&RequestBody);

FJsonSerializer::Serialize(RequestObj, Writer);


Request->SetContentAsString(RequestBody);


Request->ProcessRequest();


UE_LOG(LogTemp, Warning, TEXT("HttpCall url : %s\nrequestBody : %s"), *InURL, *RequestBody);

}



void ATestProjectGameModeBase::OnResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)

{

UE_LOG(LogTemp, Warning, TEXT("OnResponseReceived url : %s\nrecv : %s"), *Request->GetURL(), *Response->GetContentAsString());


//Create a pointer to hold the json serialized data

TSharedPtr<FJsonObject> JsonObject;


//Create a reader pointer to read the json data

TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Response->GetContentAsString());


//Deserialize the json data given Reader and the actual object to deserialize

if (FJsonSerializer::Deserialize(Reader, JsonObject))

{

//Get the value of the json object by field name

int32 recievedInt = JsonObject->GetIntegerField("customInt");


UE_LOG(LogTemp, Warning, TEXT("HTTP request result customInt : %d"), recievedInt);

}

}





OnResponseReceived ํ•จ์ˆ˜๋Š” ์ž‘๋™์•ˆํ•˜๋Š”๊ฒŒ ์ •์ƒ์ธ๊ฑฐ์•ผ??
์ œ์ด์Šจ ํŒŒ์„œ๊ด€๋ จ ์˜ˆ์ œ๋“ค ๋‹ค ์ฝœ๋ฐฑ์œผ๋กœ ํ•ด๋†ง๋˜๋ฐ ๋ฆฌ์Šคํฐ๊ฐ’ ๋‹ค ์•ˆ๋ฐ›์•„์ง„๋‹ค ใ… ใ…  ์ข€๋„์™€์ค˜