Commit 9a8bfd82 authored by Geovanny Vera's avatar Geovanny Vera

Meetings get

parent 4c983992
......@@ -25,7 +25,7 @@ DefaultGraphicsPerformance=Scalable
AppliedDefaultGraphicsPerformance=Scalable
[/Script/EngineSettings.GameMapsSettings]
EditorStartupMap=/Game/Campus/Maps/MainMenu.MainMenu
EditorStartupMap=/Game/Campus/Maps/Login.Login
LocalMapOptions=
TransitionMap=None
bUseSplitscreen=False
......@@ -34,7 +34,7 @@ ThreePlayerSplitscreenLayout=FavorTop
FourPlayerSplitscreenLayout=Grid
bOffsetPlayerGamepadIds=False
GameInstanceClass=/Script/VRClassroom.VRCGameInstance
GameDefaultMap=/Game/Campus/Maps/MainMenu.MainMenu
GameDefaultMap=/Game/Campus/Maps/Login.Login
ServerDefaultMap=/Game/Campus/Maps/TestServer.TestServer
GlobalDefaultGameMode=/Game/Campus/Blueprints/BP_GameMode.BP_GameMode_C
GlobalDefaultServerGameMode=None
......
......@@ -4,6 +4,7 @@
#include "HttpService.h"
#include "Runtime/Core/Public/Misc/ConfigCacheIni.h"
#include "Runtime/Online/HTTP/Public/Http.h"
#include "VRCGameInstance.h"
UHttpService::UHttpService(const class FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
......@@ -24,8 +25,25 @@ UHttpService* UHttpService::GetHttp() {
}
void UHttpService::SetAuthToken(FString token) {
AuthToken = "Bearer ";
AuthToken.Append(token);
if (AuthToken.IsEmpty()) {
UE_LOG(LogTemp, Log, TEXT("Kill me"));
}
else {
UE_LOG(LogTemp, Log, TEXT("I don't know anymore"));
}
FString killme = FString("Bearer ");
killme.Append(token);
//AuthToken = FString("Bearer ");
//AuthToken.Empty();
//AuthToken.Append(*killme);
}
FString UHttpService::GetAuthToken() {
FString why = FString("Bearer ");
UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance());
why.Append(GameInstance->GetUserToken());
return why;
}
void UHttpService::SetTimeout(float Timeout) {
......@@ -81,10 +99,14 @@ TSharedRef<IHttpRequest> UHttpService::GetRequest(FString Subroute) {
TSharedRef<IHttpRequest> UHttpService::AuthPostRequest(FString Subroute, FString ContentJsonString) {
TSharedRef<IHttpRequest> Request = PostRequest(Subroute, ContentJsonString);
Request->SetHeader("Authorization", AuthToken);
Request->SetHeader("Authorization", GetAuthToken());
return Request;
}
TSharedRef<IHttpRequest> UHttpService::AuthGetRequest(FString Subroute) {
TSharedRef<IHttpRequest> Request = GetRequest(Subroute);
Request->SetHeader("Authorization", AuthToken);
Request->SetHeader("Authorization", GetAuthToken());
return Request;
}
\ No newline at end of file
......@@ -19,17 +19,17 @@ void AVRCPlayerController::ConnectToCampus() {
UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance());
Http = GameInstance->GetHttpService();
//FString token = GameInstance->GetUserToken();
FString token = GameInstance->GetUserToken();
Http->SetTimeout(TravelTimeout);
TSharedRef<IHttpRequest> Request = Http->AuthGetRequest("instances/join-server");
TSharedRef<IHttpRequest> Request = Http->GetRequest("instances/join-server");
Request->OnProcessRequestComplete().BindUObject(this, &AVRCPlayerController::OnConnectToCampusResponseRecieved);
Request->SetHeader("Accepts", TEXT("application/json"));
//FString auth = "Bearer ";
//auth.Append(token);
//Request->SetHeader("Authorization", auth);
FString auth = "Bearer ";
auth.Append(token);
Request->SetHeader("Authorization", auth);
//FString url = FString(VRCAPIPath + "instances/join-server");
......@@ -68,15 +68,19 @@ void AVRCPlayerController::ConnectToMeeting(int32 MeetingId) {
UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance());
Http = GameInstance->GetHttpService();
FString token = GameInstance->GetUserToken();
Http->SetTimeout(20.0f);
FString SubRoute = "instances/join-classroom/";
SubRoute.AppendInt(MeetingId);
TSharedRef<IHttpRequest> Request = Http->AuthGetRequest(SubRoute);
TSharedRef<IHttpRequest> Request = Http->GetRequest(SubRoute);
//FString url = "http://localhost:1337/instances/join-classroom/";
//url.AppendInt(MeetingId);
//Request->SetURL(url);
FString auth = "Bearer ";
auth.Append(token);
Request->SetHeader("Authorization", auth);
Request->SetHeader("Accepts", TEXT("application/json"));
Request->OnProcessRequestComplete().BindUObject(this, &AVRCPlayerController::OnConnectToMeetingResponseRecieved);
......
......@@ -10,17 +10,17 @@ void UVRCScheduleWidget::GetMeetings() {
UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance());
Http = GameInstance->GetHttpService();
//FString token = GameInstance->GetUserToken();
FString token = GameInstance->GetUserToken();
Http->SetTimeout(20.0f);
Http->SetTimeout(5.0f);
TSharedRef<IHttpRequest> Request = Http->AuthGetRequest("users/meetings");
TSharedRef<IHttpRequest> Request = Http->GetRequest("users/meetings");
//Request->SetURL(FString("http://localhost:1337/users/meetings"));
Request->SetHeader("Accepts", TEXT("application/json"));
Request->OnProcessRequestComplete().BindUObject(this, &UVRCScheduleWidget::OnGetMeetingsResponseRecieved);
//FString auth = "Bearer ";
//auth.Append(token);
//Request->SetHeader("Authorization", auth);
FString auth = "Bearer ";
auth.Append(token);
Request->SetHeader("Authorization", auth);
Request->ProcessRequest();
//Testy();
......@@ -48,7 +48,7 @@ void UVRCScheduleWidget::OnGetMeetingsResponseRecieved(FHttpRequestPtr Request,
FString content = FString(Response->GetContentAsString());
if (FJsonObjectConverter::JsonArrayStringToUStruct(content, &responseMeetings, 0, 0)) {
meetings = responseMeetings;
UE_LOG(LogTemp, Log, TEXT("Meetings found: %d", meetings.Num));
UE_LOG(LogTemp, Log, TEXT("Meetings found"));
NotifyGetMeetings();
}
......
// Copyright 2020 Testy
#include "VRCWidgetComponent.h"
void UVRCWidgetComponent::ToggleWidget(bool toggle) {
bToggleWidget = toggle;
this->SetVisibility(bToggleWidget);
if (bToggleWidget) {
this->SetCollisionEnabled(ECollisionEnabled::QueryOnly);
}
else {
this->SetCollisionEnabled(ECollisionEnabled::NoCollision);
}
}
\ No newline at end of file
......@@ -15,7 +15,7 @@ class VRCLASSROOM_API UHttpService : public UObject
GENERATED_BODY()
FHttpModule* Http;
FString AuthToken = "";
FString AuthToken;
public:
......@@ -27,6 +27,8 @@ public:
void SetAuthToken(FString token);
FString GetAuthToken();
void SetTimeout(float Timeout);
bool ResponseIsValid(FHttpResponsePtr Response, bool bWasSuccessful);
......
// Copyright 2020 Testy
#pragma once
#include "CoreMinimal.h"
#include "Components/WidgetComponent.h"
#include "VRCWidgetComponent.generated.h"
/**
*
*/
UCLASS(ClassGroup = (Custom), Blueprintable, meta = (BlueprintSpawnableComponent))
class VRCLASSROOM_API UVRCWidgetComponent : public UWidgetComponent
{
GENERATED_BODY()
bool bToggleWidget;
public:
UFUNCTION(BlueprintCallable, Category = "Widget")
void ToggleWidget(bool toggle);
};
{
"FileVersion": 3,
<<<<<<< HEAD
"EngineAssociation": "{0506F437-410D-A1AD-0DE5-36A1D1C0C5F7}",
=======
"EngineAssociation": "{7E4506D0-4E9A-9CE5-C703-1FAFBE0E6174}",
>>>>>>> 50f7ad7d559929fa644f71b77304290f2c4d15cf
"Category": "",
"Description": "",
"Modules": [
......
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