Commit fc490c21 authored by Geovanny Vera's avatar Geovanny Vera

Recycle instances and widges for clients side only

parent fe1266e3
......@@ -21,8 +21,8 @@ async function main(){
const ip = await publicIp.v4();
UE_CONFIG.ip = ip;
//const api = 'https://api.ev3.me/';
const api = 'http://localhost:1337/';
const api = 'https://api.ev3.me/';
//const api = 'http://localhost:1337/';
const response = await fetch(`${api}instances/add-world-server`, {
headers: {
......
......@@ -26,7 +26,7 @@ UHttpService* UHttpService::GetHttp() {
void UHttpService::SetAuthToken(FString token) {
if (AuthToken.IsEmpty()) {
UE_LOG(LogTemp, Log, TEXT("Kill me"));
UE_LOG(LogTemp, Log, TEXT("asd me"));
}
else {
UE_LOG(LogTemp, Log, TEXT("I don't know anymore"));
......@@ -69,8 +69,8 @@ void UHttpService::SetRequestHeaders(TSharedRef<IHttpRequest>& Request) {
TSharedRef<IHttpRequest> UHttpService::RequestWithRoute(FString Subroute) {
// I have to set it here because for some reason if I set it on the constructor it becomes empty when it reaches here
// TODO: Figure out why that happens and fix it to remove this line
//FString VRCAPIPath1 = FString(TEXT("https://api.ev3.me/"));
FString VRCAPIPath1 = FString(TEXT("http://localhost:1337/"));
FString VRCAPIPath1 = FString(TEXT("https://api.ev3.me/"));
//FString VRCAPIPath1 = FString(TEXT("http://localhost:1337/"));
Http = &FHttpModule::Get();
TSharedRef<IHttpRequest> Request = Http->CreateRequest();
......
......@@ -39,8 +39,7 @@ void AVRCGameMode::RemoveInstanceFromAPI(const FString& route, const FString& IP
void AVRCGameMode::OnRemoveInstanceFromAPI(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) {
if (Http->ResponseIsValid(Response, bWasSuccessful)) {
UE_LOG(LogTemp, Log, TEXT("Shutting Down!"));
ShutDown();
NotifyRemoveInstanceFromAPI();
}
else {
UE_LOG(LogTemp, Error, TEXT("OnRemoveInstanceFromAPI Error removing from API!"));
......
......@@ -15,7 +15,7 @@ void AVRCPlayerController::TravelToMap(const FString& URL, const bool SeamlessTr
ClientTravel(URL, TRAVEL_Absolute, false, FGuid());
}
void AVRCPlayerController::ConnectToCampus() {
void AVRCPlayerController::ConnectToHub() {
UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance());
Http = GameInstance->GetHttpService();
......@@ -24,7 +24,7 @@ void AVRCPlayerController::ConnectToCampus() {
Http->SetTimeout(TravelTimeout);
TSharedRef<IHttpRequest> Request = Http->GetRequest("instances/join-server");
Request->OnProcessRequestComplete().BindUObject(this, &AVRCPlayerController::OnConnectToCampusResponseRecieved);
Request->OnProcessRequestComplete().BindUObject(this, &AVRCPlayerController::OnConnectToHubResponseRecieved);
Request->SetHeader("Accepts", TEXT("application/json"));
FString auth = "Bearer ";
......@@ -34,7 +34,7 @@ void AVRCPlayerController::ConnectToCampus() {
Request->ProcessRequest();
}
void AVRCPlayerController::OnConnectToCampusResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
void AVRCPlayerController::OnConnectToHubResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
{
if (Http->ResponseIsValid(Response, bWasSuccessful)) {
TSharedPtr<FJsonObject> JsonObject;
......@@ -46,17 +46,17 @@ void AVRCPlayerController::OnConnectToCampusResponseRecieved(FHttpRequestPtr Req
FString PORT = JsonObject->GetStringField("port");
FString URL = IP + FString(TEXT(":")) + PORT.Left(4);
UE_LOG(LogTemp, Log, TEXT("OnConnectToCampus IP is %s Port %s, Both"), *IP, *PORT, *URL);
UE_LOG(LogTemp, Log, TEXT("OnConnectToHub IP is %s Port %s, Both"), *IP, *PORT, *URL);
TravelToMap(URL, false);
TravelToMap(URL, true);
}
else {
UE_LOG(LogTemp, Error, TEXT("OnConnectToCampus Server returned no data!"));
UE_LOG(LogTemp, Error, TEXT("OnConnectToHub Server returned no data!"));
}
}
else {
UE_LOG(LogTemp, Error, TEXT("OnConnectToCampus Error accessing server!"));
UE_LOG(LogTemp, Error, TEXT("OnConnectToHub Error accessing server!"));
}
}
......@@ -98,7 +98,7 @@ void AVRCPlayerController::OnConnectToMeetingResponseRecieved(FHttpRequestPtr Re
FString URL = IP + FString(TEXT(":")) + PORT.Left(4);
UE_LOG(LogTemp, Log, TEXT("OnConnectToMeeting IP is %s Port %s, Both"), *IP, *PORT, *URL);
TravelToMap(URL, false);
TravelToMap(URL, true);
}
else {
UE_LOG(LogTemp, Error, TEXT("OnConnectToMeeting Server returned no data!"));
......
......@@ -36,5 +36,8 @@ public:
void RemoveMeetingFromAPI(const FString& IP, const FString& PORT);
void OnRemoveInstanceFromAPI(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
UFUNCTION(BlueprintImplementableEvent, Category = "API")
void NotifyRemoveInstanceFromAPI();
};
......@@ -42,9 +42,9 @@ public:
void TravelToMap(const FString& URL, const bool SeamlessTravel);
UFUNCTION(BlueprintCallable, Category = "Travel")
void ConnectToCampus();
void ConnectToHub();
void OnConnectToCampusResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
void OnConnectToHubResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
UFUNCTION(BlueprintCallable, Category = "Travel")
void ConnectToMeeting(int32 MeetingId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment