Commit 1f9e40be authored by Danny Pires's avatar Danny Pires 💬

Merge branch 'first_demo' into 'master'

First demo

See merge request !7
parents 50f7ad7d 9a8bfd82
...@@ -25,7 +25,7 @@ DefaultGraphicsPerformance=Scalable ...@@ -25,7 +25,7 @@ DefaultGraphicsPerformance=Scalable
AppliedDefaultGraphicsPerformance=Scalable AppliedDefaultGraphicsPerformance=Scalable
[/Script/EngineSettings.GameMapsSettings] [/Script/EngineSettings.GameMapsSettings]
EditorStartupMap=/Game/Campus/Maps/MainMenu.MainMenu EditorStartupMap=/Game/Campus/Maps/Login.Login
LocalMapOptions= LocalMapOptions=
TransitionMap=None TransitionMap=None
bUseSplitscreen=False bUseSplitscreen=False
...@@ -34,7 +34,7 @@ ThreePlayerSplitscreenLayout=FavorTop ...@@ -34,7 +34,7 @@ ThreePlayerSplitscreenLayout=FavorTop
FourPlayerSplitscreenLayout=Grid FourPlayerSplitscreenLayout=Grid
bOffsetPlayerGamepadIds=False bOffsetPlayerGamepadIds=False
GameInstanceClass=/Script/VRClassroom.VRCGameInstance GameInstanceClass=/Script/VRClassroom.VRCGameInstance
GameDefaultMap=/Game/Campus/Maps/MainMenu.MainMenu GameDefaultMap=/Game/Campus/Maps/Login.Login
ServerDefaultMap=/Game/Campus/Maps/TestServer.TestServer ServerDefaultMap=/Game/Campus/Maps/TestServer.TestServer
GlobalDefaultGameMode=/Game/Campus/Blueprints/BP_GameMode.BP_GameMode_C GlobalDefaultGameMode=/Game/Campus/Blueprints/BP_GameMode.BP_GameMode_C
GlobalDefaultServerGameMode=None GlobalDefaultServerGameMode=None
...@@ -361,3 +361,6 @@ net.MaxRepArraySize=65535 ...@@ -361,3 +361,6 @@ net.MaxRepArraySize=65535
+CollisionChannelRedirects=(OldName="VehicleMovement",NewName="Vehicle") +CollisionChannelRedirects=(OldName="VehicleMovement",NewName="Vehicle")
+CollisionChannelRedirects=(OldName="PawnMovement",NewName="Pawn") +CollisionChannelRedirects=(OldName="PawnMovement",NewName="Pawn")
[/Script/OculusHMD.OculusHMDRuntimeSettings]
bRequiresSystemKeyboard=True
...@@ -158,43 +158,13 @@ DoubleClickTime=0.200000 ...@@ -158,43 +158,13 @@ DoubleClickTime=0.200000
+ActionMappings=(ActionName="TriggerRight",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=OculusTouch_Right_Trigger_Click) +ActionMappings=(ActionName="TriggerRight",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=OculusTouch_Right_Trigger_Click)
+ActionMappings=(ActionName="TriggerLeft",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=OculusTouch_Left_Trigger_Click) +ActionMappings=(ActionName="TriggerLeft",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=OculusTouch_Left_Trigger_Click)
+ActionMappings=(ActionName="TeleportRight",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar) +ActionMappings=(ActionName="TeleportRight",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar)
+AxisMappings=(AxisName="TeleportDirectionUp",Scale=1.000000,Key=Gamepad_LeftY)
+AxisMappings=(AxisName="TeleportDirectionRight",Scale=1.000000,Key=Gamepad_LeftX)
+AxisMappings=(AxisName="MotionControllerThumbLeft_Y",Scale=1.000000,Key=Vive_Left_Trackpad_Y)
+AxisMappings=(AxisName="MotionControllerThumbLeft_Y",Scale=1.000000,Key=OculusTouch_Left_Thumbstick_Y)
+AxisMappings=(AxisName="MotionControllerThumbLeft_Y",Scale=1.000000,Key=ValveIndex_Left_Thumbstick_Y)
+AxisMappings=(AxisName="MotionControllerThumbLeft_Y",Scale=1.000000,Key=MixedReality_Left_Thumbstick_Y)
+AxisMappings=(AxisName="MotionControllerThumbLeft_Y",Scale=1.000000,Key=OculusGo_Left_Trackpad_Y)
+AxisMappings=(AxisName="MotionControllerThumbLeft_X",Scale=1.000000,Key=Vive_Left_Trackpad_X)
+AxisMappings=(AxisName="MotionControllerThumbLeft_X",Scale=1.000000,Key=OculusTouch_Left_Thumbstick_X)
+AxisMappings=(AxisName="MotionControllerThumbLeft_X",Scale=1.000000,Key=ValveIndex_Left_Thumbstick_X)
+AxisMappings=(AxisName="MotionControllerThumbLeft_X",Scale=1.000000,Key=MixedReality_Left_Thumbstick_X)
+AxisMappings=(AxisName="MotionControllerThumbLeft_X",Scale=1.000000,Key=OculusGo_Left_Trackpad_X)
+AxisMappings=(AxisName="MotionControllerThumbRight_Y",Scale=1.000000,Key=Vive_Right_Trackpad_Y)
+AxisMappings=(AxisName="MotionControllerThumbRight_Y",Scale=1.000000,Key=OculusTouch_Right_Thumbstick_Y)
+AxisMappings=(AxisName="MotionControllerThumbRight_Y",Scale=1.000000,Key=ValveIndex_Right_Thumbstick_Y)
+AxisMappings=(AxisName="MotionControllerThumbRight_Y",Scale=1.000000,Key=MixedReality_Right_Thumbstick_Y)
+AxisMappings=(AxisName="MotionControllerThumbRight_Y",Scale=1.000000,Key=OculusGo_Right_Trackpad_Y)
+AxisMappings=(AxisName="MotionControllerThumbRight_X",Scale=1.000000,Key=Vive_Right_Trackpad_X)
+AxisMappings=(AxisName="MotionControllerThumbRight_X",Scale=1.000000,Key=OculusTouch_Right_Thumbstick_X)
+AxisMappings=(AxisName="MotionControllerThumbRight_X",Scale=1.000000,Key=ValveIndex_Right_Thumbstick_X)
+AxisMappings=(AxisName="MotionControllerThumbRight_X",Scale=1.000000,Key=MixedReality_Right_Thumbstick_X)
+AxisMappings=(AxisName="MotionControllerThumbRight_X",Scale=1.000000,Key=OculusGo_Right_Trackpad_X)
+AxisMappings=(AxisName="MotionControllerThumbLeft_Y",Scale=1.000000,Key=Daydream_Left_Trackpad_Y)
+AxisMappings=(AxisName="MotionControllerThumbLeft_X",Scale=1.000000,Key=Daydream_Left_Trackpad_X)
+AxisMappings=(AxisName="MotionControllerThumbRight_Y",Scale=1.000000,Key=Daydream_Right_Trackpad_Y)
+AxisMappings=(AxisName="MotionControllerThumbRight_X",Scale=1.000000,Key=Daydream_Right_Trackpad_X)
+AxisMappings=(AxisName="MotionControllerThumbRight_Y",Scale=1.000000,Key=MagicLeap_Right_Trackpad_Y)
+AxisMappings=(AxisName="MotionControllerThumbRight_X",Scale=1.000000,Key=MagicLeap_Right_Trackpad_X)
+AxisMappings=(AxisName="MotionControllerThumbLeft_Y",Scale=1.000000,Key=MagicLeap_Left_Trackpad_Y)
+AxisMappings=(AxisName="MotionControllerThumbLeft_X",Scale=1.000000,Key=MagicLeap_Left_Trackpad_X)
+ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar) +ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=SpaceBar)
+ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Gamepad_FaceButton_Bottom) +ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Gamepad_FaceButton_Bottom)
+ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=MotionController_Left_Trigger) +ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=MotionController_Left_Trigger)
+ActionMappings=(ActionName="ResetVR",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=R) +ActionMappings=(ActionName="ResetVR",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=R)
+ActionMappings=(ActionName="ResetVR",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=MotionController_Left_Grip1) +ActionMappings=(ActionName="ResetVR",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=MotionController_Left_Grip1)
+ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=MotionController_Right_Trigger) +ActionMappings=(ActionName="Jump",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=MotionController_Right_Trigger)
+ActionMappings=(ActionName="UseAbility1",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=One) +ActionMappings=(ActionName="ToggleKeyboard",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=OculusTouch_Right_B_Click)
+ActionMappings=(ActionName="UseAbility2",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Two) +ActionMappings=(ActionName="UseAbility2",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Two)
+ActionMappings=(ActionName="UseAbility3",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Three) +ActionMappings=(ActionName="UseAbility3",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Three)
+ActionMappings=(ActionName="UseAbility4",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Four) +ActionMappings=(ActionName="UseAbility4",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Four)
...@@ -234,6 +204,36 @@ DoubleClickTime=0.200000 ...@@ -234,6 +204,36 @@ DoubleClickTime=0.200000
+ActionMappings=(ActionName="ClearTarget",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=BackSpace) +ActionMappings=(ActionName="ClearTarget",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=BackSpace)
+ActionMappings=(ActionName="SelectTargetOrPressSwitch",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=RightMouseButton) +ActionMappings=(ActionName="SelectTargetOrPressSwitch",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=RightMouseButton)
+ActionMappings=(ActionName="TeleportOutOfDungeon",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=T) +ActionMappings=(ActionName="TeleportOutOfDungeon",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=T)
+AxisMappings=(AxisName="TeleportDirectionUp",Scale=1.000000,Key=Gamepad_LeftY)
+AxisMappings=(AxisName="TeleportDirectionRight",Scale=1.000000,Key=Gamepad_LeftX)
+AxisMappings=(AxisName="MotionControllerThumbLeft_Y",Scale=1.000000,Key=Vive_Left_Trackpad_Y)
+AxisMappings=(AxisName="MotionControllerThumbLeft_Y",Scale=1.000000,Key=OculusTouch_Left_Thumbstick_Y)
+AxisMappings=(AxisName="MotionControllerThumbLeft_Y",Scale=1.000000,Key=ValveIndex_Left_Thumbstick_Y)
+AxisMappings=(AxisName="MotionControllerThumbLeft_Y",Scale=1.000000,Key=MixedReality_Left_Thumbstick_Y)
+AxisMappings=(AxisName="MotionControllerThumbLeft_Y",Scale=1.000000,Key=OculusGo_Left_Trackpad_Y)
+AxisMappings=(AxisName="MotionControllerThumbLeft_X",Scale=1.000000,Key=Vive_Left_Trackpad_X)
+AxisMappings=(AxisName="MotionControllerThumbLeft_X",Scale=1.000000,Key=OculusTouch_Left_Thumbstick_X)
+AxisMappings=(AxisName="MotionControllerThumbLeft_X",Scale=1.000000,Key=ValveIndex_Left_Thumbstick_X)
+AxisMappings=(AxisName="MotionControllerThumbLeft_X",Scale=1.000000,Key=MixedReality_Left_Thumbstick_X)
+AxisMappings=(AxisName="MotionControllerThumbLeft_X",Scale=1.000000,Key=OculusGo_Left_Trackpad_X)
+AxisMappings=(AxisName="MotionControllerThumbRight_Y",Scale=1.000000,Key=Vive_Right_Trackpad_Y)
+AxisMappings=(AxisName="MotionControllerThumbRight_Y",Scale=1.000000,Key=OculusTouch_Right_Thumbstick_Y)
+AxisMappings=(AxisName="MotionControllerThumbRight_Y",Scale=1.000000,Key=ValveIndex_Right_Thumbstick_Y)
+AxisMappings=(AxisName="MotionControllerThumbRight_Y",Scale=1.000000,Key=MixedReality_Right_Thumbstick_Y)
+AxisMappings=(AxisName="MotionControllerThumbRight_Y",Scale=1.000000,Key=OculusGo_Right_Trackpad_Y)
+AxisMappings=(AxisName="MotionControllerThumbRight_X",Scale=1.000000,Key=Vive_Right_Trackpad_X)
+AxisMappings=(AxisName="MotionControllerThumbRight_X",Scale=1.000000,Key=OculusTouch_Right_Thumbstick_X)
+AxisMappings=(AxisName="MotionControllerThumbRight_X",Scale=1.000000,Key=ValveIndex_Right_Thumbstick_X)
+AxisMappings=(AxisName="MotionControllerThumbRight_X",Scale=1.000000,Key=MixedReality_Right_Thumbstick_X)
+AxisMappings=(AxisName="MotionControllerThumbRight_X",Scale=1.000000,Key=OculusGo_Right_Trackpad_X)
+AxisMappings=(AxisName="MotionControllerThumbLeft_Y",Scale=1.000000,Key=Daydream_Left_Trackpad_Y)
+AxisMappings=(AxisName="MotionControllerThumbLeft_X",Scale=1.000000,Key=Daydream_Left_Trackpad_X)
+AxisMappings=(AxisName="MotionControllerThumbRight_Y",Scale=1.000000,Key=Daydream_Right_Trackpad_Y)
+AxisMappings=(AxisName="MotionControllerThumbRight_X",Scale=1.000000,Key=Daydream_Right_Trackpad_X)
+AxisMappings=(AxisName="MotionControllerThumbRight_Y",Scale=1.000000,Key=MagicLeap_Right_Trackpad_Y)
+AxisMappings=(AxisName="MotionControllerThumbRight_X",Scale=1.000000,Key=MagicLeap_Right_Trackpad_X)
+AxisMappings=(AxisName="MotionControllerThumbLeft_Y",Scale=1.000000,Key=MagicLeap_Left_Trackpad_Y)
+AxisMappings=(AxisName="MotionControllerThumbLeft_X",Scale=1.000000,Key=MagicLeap_Left_Trackpad_X)
+AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=W) +AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=W)
+AxisMappings=(AxisName="MoveForward",Scale=-1.000000,Key=S) +AxisMappings=(AxisName="MoveForward",Scale=-1.000000,Key=S)
+AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=Up) +AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=Up)
......
...@@ -16,7 +16,7 @@ async function main(){ ...@@ -16,7 +16,7 @@ async function main(){
app.use(router.routes()).use(router.allowedMethods()); app.use(router.routes()).use(router.allowedMethods());
const response = await fetch('http://localhost:1337/instances/add-world-server'); const response = await fetch('https://api.ev3.me/instances/add-world-server');
// const data = await response.json(); // const data = await response.json();
// console.log(data); // console.log(data);
......
const config = { const config = {
UE4_PATH: "C:\\UnrealEngine-4.25.3-release\\Engine\\Binaries\\Win64\\UE4Editor.exe", UE4_PATH: "C:\\UE4-oculus-4.25.4\\Engine\\Binaries\\Win64\\UE4Editor.exe",
PROJECT_PATH: "C:\\Users\\geova\\OneDrive\\Documents\\Unreal Projects\\VRClassroom 4.25\\src\\VRClassroom.uproject", PROJECT_PATH: "C:\\Users\\geova\\OneDrive\\Documents\\Unreal Projects\\VRClassroom 4.25\\src\\VRClassroom.uproject",
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "HttpService.h" #include "HttpService.h"
#include "Runtime/Core/Public/Misc/ConfigCacheIni.h" #include "Runtime/Core/Public/Misc/ConfigCacheIni.h"
#include "Runtime/Online/HTTP/Public/Http.h" #include "Runtime/Online/HTTP/Public/Http.h"
#include "VRCGameInstance.h"
UHttpService::UHttpService(const class FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) UHttpService::UHttpService(const class FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{ {
...@@ -23,13 +24,29 @@ UHttpService* UHttpService::GetHttp() { ...@@ -23,13 +24,29 @@ UHttpService* UHttpService::GetHttp() {
return this; return this;
} }
void UHttpService::SetTimeout(float Timeout) { void UHttpService::SetAuthToken(FString token) {
if (this == NULL) { if (AuthToken.IsEmpty()) {
UE_LOG(LogTemp, Log, TEXT("TU PUTA MADRE")); UE_LOG(LogTemp, Log, TEXT("Kill me"));
} }
else if(this->Http == NULL) { else {
UE_LOG(LogTemp, Log, TEXT("LA TUYA")); 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) {
Http->SetHttpTimeout(Timeout); Http->SetHttpTimeout(Timeout);
} }
...@@ -79,3 +96,17 @@ TSharedRef<IHttpRequest> UHttpService::GetRequest(FString Subroute) { ...@@ -79,3 +96,17 @@ TSharedRef<IHttpRequest> UHttpService::GetRequest(FString Subroute) {
return Request; return Request;
} }
TSharedRef<IHttpRequest> UHttpService::AuthPostRequest(FString Subroute, FString ContentJsonString) {
TSharedRef<IHttpRequest> Request = PostRequest(Subroute, ContentJsonString);
Request->SetHeader("Authorization", GetAuthToken());
return Request;
}
TSharedRef<IHttpRequest> UHttpService::AuthGetRequest(FString Subroute) {
TSharedRef<IHttpRequest> Request = GetRequest(Subroute);
Request->SetHeader("Authorization", GetAuthToken());
return Request;
}
\ No newline at end of file
...@@ -11,3 +11,12 @@ UVRCGameInstance::UVRCGameInstance(const class FObjectInitializer& ObjectInitial ...@@ -11,3 +11,12 @@ UVRCGameInstance::UVRCGameInstance(const class FObjectInitializer& ObjectInitial
UHttpService* UVRCGameInstance::GetHttpService() { UHttpService* UVRCGameInstance::GetHttpService() {
return Http->GetHttp(); return Http->GetHttp();
} }
void UVRCGameInstance::SetUserToken(FString token) {
User.Token = token;
Http->SetAuthToken(token);
}
FString UVRCGameInstance::GetUserToken() {
return User.Token;
}
...@@ -16,19 +16,24 @@ void AVRCPlayerController::TravelToMap(const FString& URL, const bool SeamlessTr ...@@ -16,19 +16,24 @@ void AVRCPlayerController::TravelToMap(const FString& URL, const bool SeamlessTr
} }
void AVRCPlayerController::ConnectToCampus() { void AVRCPlayerController::ConnectToCampus() {
if (Http == NULL) {
UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance()); UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance());
Http = GameInstance->GetHttpService(); Http = GameInstance->GetHttpService();
} FString token = GameInstance->GetUserToken();
Http->SetTimeout(TravelTimeout); Http->SetTimeout(TravelTimeout);
TSharedRef<IHttpRequest> Request = Http->GetRequest("instances/join-server"); TSharedRef<IHttpRequest> Request = Http->GetRequest("instances/join-server");
Request->OnProcessRequestComplete().BindUObject(this, &AVRCPlayerController::OnConnectToCampusResponseRecieved); Request->OnProcessRequestComplete().BindUObject(this, &AVRCPlayerController::OnConnectToCampusResponseRecieved);
Request->SetHeader("Accepts", TEXT("application/json")); Request->SetHeader("Accepts", TEXT("application/json"));
FString url = FString(VRCAPIPath + "instances/join-server"); FString auth = "Bearer ";
auth.Append(token);
Request->SetHeader("Authorization", auth);
//FString url = FString(VRCAPIPath + "instances/join-server");
Request->SetURL(url); //Request->SetURL(url);
Request->ProcessRequest(); Request->ProcessRequest();
} }
...@@ -59,17 +64,23 @@ void AVRCPlayerController::OnConnectToCampusResponseRecieved(FHttpRequestPtr Req ...@@ -59,17 +64,23 @@ void AVRCPlayerController::OnConnectToCampusResponseRecieved(FHttpRequestPtr Req
} }
void AVRCPlayerController::ConnectToMeeting(FString MeetingId) { void AVRCPlayerController::ConnectToMeeting(int32 MeetingId) {
if (Http == NULL) {
UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance()); UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance());
Http = GameInstance->GetHttpService(); Http = GameInstance->GetHttpService();
} FString token = GameInstance->GetUserToken();
Http->SetTimeout(20.0f);
MeetingId.TrimStartAndEndInline(); Http->SetTimeout(20.0f);
TSharedRef<IHttpRequest> Request = Http->GetRequest("instances/join-classroom/123"); FString SubRoute = "instances/join-classroom/";
Request->SetURL(FString("http://localhost:1337/instances/join-classroom/123")); SubRoute.AppendInt(MeetingId);
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->SetHeader("Accepts", TEXT("application/json"));
Request->OnProcessRequestComplete().BindUObject(this, &AVRCPlayerController::OnConnectToMeetingResponseRecieved); Request->OnProcessRequestComplete().BindUObject(this, &AVRCPlayerController::OnConnectToMeetingResponseRecieved);
......
// Copyright 2020 Testy
#include "VRCScheduleWidget.h"
#include "HttpService.h"
#include "VRCGameInstance.h"
#include "JsonObjectConverter.h"
void UVRCScheduleWidget::GetMeetings() {
UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance());
Http = GameInstance->GetHttpService();
FString token = GameInstance->GetUserToken();
Http->SetTimeout(5.0f);
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);
Request->ProcessRequest();
//Testy();
}
void UVRCScheduleWidget::Testy() {
FString asd = "[{\"id\":34,\"map_id\":1,\"name\":\"CSC123\",\"password\":\"angry\",\"repeating\":0,\"active\":0,\"creator_id\":1}]";
TArray<FMeetingInfo> responseMeetings;
if (FJsonObjectConverter::JsonArrayStringToUStruct(asd, &responseMeetings, 0, 0)) {
meetings = responseMeetings;
FMeetingInfo temp = meetings[0];
UE_LOG(LogTemp, Log, TEXT("Good shit id: %d, name: %s"), temp.id, *temp.name);
NotifyGetMeetings();
}
else {
UE_LOG(LogTemp, Log, TEXT("Bad shit"));
}
}
void UVRCScheduleWidget::OnGetMeetingsResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) {
if (Http->ResponseIsValid(Response, bWasSuccessful)) {
TArray<FMeetingInfo> responseMeetings;
FString content = FString(Response->GetContentAsString());
if (FJsonObjectConverter::JsonArrayStringToUStruct(content, &responseMeetings, 0, 0)) {
meetings = responseMeetings;
UE_LOG(LogTemp, Log, TEXT("Meetings found"));
NotifyGetMeetings();
}
else {
UE_LOG(LogTemp, Log, TEXT("No meetings found"));
}
}
else {
UE_LOG(LogTemp, Error, TEXT("GetMeetings Error accessing server!"));
}
}
\ No newline at end of file
// 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 ...@@ -15,7 +15,7 @@ class VRCLASSROOM_API UHttpService : public UObject
GENERATED_BODY() GENERATED_BODY()
FHttpModule* Http; FHttpModule* Http;
FString AuthToken;
public: public:
...@@ -25,6 +25,10 @@ public: ...@@ -25,6 +25,10 @@ public:
UHttpService* GetHttp(); UHttpService* GetHttp();
void SetAuthToken(FString token);
FString GetAuthToken();
void SetTimeout(float Timeout); void SetTimeout(float Timeout);
bool ResponseIsValid(FHttpResponsePtr Response, bool bWasSuccessful); bool ResponseIsValid(FHttpResponsePtr Response, bool bWasSuccessful);
...@@ -36,4 +40,8 @@ public: ...@@ -36,4 +40,8 @@ public:
TSharedRef<IHttpRequest> PostRequest(FString Subroute, FString ContentJsonString); TSharedRef<IHttpRequest> PostRequest(FString Subroute, FString ContentJsonString);
TSharedRef<IHttpRequest> GetRequest(FString Subroute); TSharedRef<IHttpRequest> GetRequest(FString Subroute);
TSharedRef<IHttpRequest> AuthPostRequest(FString Subroute, FString ContentJsonString);
TSharedRef<IHttpRequest> AuthGetRequest(FString Subroute);
}; };
...@@ -7,6 +7,17 @@ ...@@ -7,6 +7,17 @@
#include "HttpService.h" #include "HttpService.h"
#include "VRCGameInstance.generated.h" #include "VRCGameInstance.generated.h"
USTRUCT(BlueprintType, Blueprintable)
struct FUserData
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "API")
FString Token;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "User")
FString DisplayName;
};
/** /**
* *
*/ */
...@@ -19,7 +30,15 @@ class VRCLASSROOM_API UVRCGameInstance : public UGameInstance ...@@ -19,7 +30,15 @@ class VRCLASSROOM_API UVRCGameInstance : public UGameInstance
public: public:
UVRCGameInstance(const class FObjectInitializer& ObjectInitializer); UVRCGameInstance(const class FObjectInitializer& ObjectInitializer);
FUserData User;
UFUNCTION(BlueprintCallable, Category = "Http") UFUNCTION(BlueprintCallable, Category = "Http")
UHttpService* GetHttpService(); UHttpService* GetHttpService();
UFUNCTION(BlueprintCallable, Category = "Http")
void SetUserToken(FString token);
UFUNCTION(BlueprintCallable, Category = "Http")
FString GetUserToken();
}; };
...@@ -50,7 +50,7 @@ public: ...@@ -50,7 +50,7 @@ public:
void OnConnectToCampusResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful); void OnConnectToCampusResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
UFUNCTION(BlueprintCallable, Category = "Travel") UFUNCTION(BlueprintCallable, Category = "Travel")
void ConnectToMeeting(FString MeetingId); void ConnectToMeeting(int32 MeetingId);
void OnConnectToMeetingResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful); void OnConnectToMeetingResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
......
// Copyright 2020 Testy
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "HttpService.h"
#include "VRCGameInstance.h"
#include "VRCScheduleWidget.generated.h"
USTRUCT(BlueprintType)
struct FMeetingInfo {
GENERATED_USTRUCT_BODY()
UPROPERTY(BlueprintReadOnly)
int32 id;
UPROPERTY(BlueprintReadOnly)
int32 map_id;
UPROPERTY(BlueprintReadOnly)
FString name;
UPROPERTY(BlueprintReadOnly)
FString password;
UPROPERTY(BlueprintReadOnly)
int32 repeating;
UPROPERTY(BlueprintReadOnly)
int32 active;
UPROPERTY(BlueprintReadOnly)
int32 creator_id;
};
/**
*
*/
UCLASS()
class VRCLASSROOM_API UVRCScheduleWidget : public UUserWidget
{
GENERATED_BODY()
UHttpService* Http;
public:
UPROPERTY(BlueprintReadWrite, Category = "Meetings")
TArray<FMeetingInfo> meetings;
UFUNCTION(BlueprintCallable, Category = "Meetings")
void GetMeetings();
void Testy();
void OnGetMeetingsResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful);
UFUNCTION(BlueprintImplementableEvent, Category = "Meetings")
void NotifyGetMeetings();
};
// 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, "FileVersion": 3,
"EngineAssociation": "{7E4506D0-4E9A-9CE5-C703-1FAFBE0E6174}", "EngineAssociation": "{0506F437-410D-A1AD-0DE5-36A1D1C0C5F7}",
"Category": "", "Category": "",
"Description": "", "Description": "",
"Modules": [ "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