일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- listen server
- gameplay ability system
- ability task
- level design
- 언리얼 엔진
- photon fusion2
- 언리얼엔진
- os
- unity
- CTF
- gameplay tag
- 게임개발
- local prediction
- attribute
- Multiplay
- gameplay effect
- Replication
- rpc
- UI
- C++
- stride
- widget
- animation
- 게임 개발
- MAC
- Unreal Engine
- 유니티
- 보안
- gas
- Aegis
Archives
- Today
- Total
Replicated
[Drag Down] 배포된 백엔드에 연결 / Config 파일 사용 본문
Config 폴더에 BackendServer.ini 파일 추가
[Server]
ServerIP=
ServerPort=
그런데 IP랑 포트를 깃허브에 올려두기 싫은 상황
그래도 서버 IP랑 포트 양식은 남기고 싶음
이렇게만 푸시해두고
git update-index --skip-worktree Config/BackendServer.ini
해당 파일 깃이 무시하도록 설정. 이러면 브랜치 전환 시에도 무시함
로컬에만 IP랑 Port 값을 써둘 수 있음
void UDDHttpApiSubsystem::Initialize(FSubsystemCollectionBase& Collection)
{
SetAddress();
const FString ConfigFilePath = FPaths::ProjectConfigDir() + TEXT("BackendServer.ini");
GConfig->GetString(TEXT("Server"), TEXT("ServerIP"), ServerIP, ConfigFilePath);
GConfig->GetString(TEXT("Server"), TEXT("ServerPort"), ServerPort, ConfigFilePath);
}
경로 지정하고 가져올 수 있음
void UDDHttpApiSubsystem::SendRegisterRequest(const FString& Username, const FString& Email, const FString& Password)
{
//FString Url = TEXT("http://localhost:8080/api/auth/register");
FString Url = FString::Printf(TEXT("http://%s:%s/api/auth/register"), *ServerIP, *ServerPort);
TSharedPtr<FJsonObject> JsonObject = MakeShareable(new FJsonObject());
JsonObject->SetStringField(TEXT("username"), Username);
JsonObject->SetStringField(TEXT("email"), Email);
JsonObject->SetStringField(TEXT("password"), Password);
FString OutputString;
TSharedRef<TJsonWriter<>> Writer = TJsonWriterFactory<>::Create(&OutputString);
FJsonSerializer::Serialize(JsonObject.ToSharedRef(), Writer);
TSharedRef<IHttpRequest, ESPMode::ThreadSafe> Request = FHttpModule::Get().CreateRequest();
Request->SetURL(Url);
Request->SetVerb("POST");
Request->SetHeader("Content-Type", "application/json");
Request->SetContentAsString(OutputString);
Request->OnProcessRequestComplete().BindUObject(this, &UDDHttpApiSubsystem::OnRegisterResponseReceived);
Request->ProcessRequest();
}
기존 코드에서 서버의 IP와 포트를 사용하도록 변경
'언리얼 엔진 > Drag Down' 카테고리의 다른 글
[Drag Down] 게임 엔딩 제작 (0) | 2025.06.01 |
---|---|
[Drag Down] 맵디자인 테마3, 눈 (0) | 2025.06.01 |
[Drag Down] Patrol 몬스터 추가 (0) | 2025.05.26 |
** [Drag Down] 채팅 기능 구현 (Chatting) ** (0) | 2025.05.24 |
[Drag Down] 맵 이동 포탈 (0) | 2025.05.21 |