Commit de7c8ba5 authored by Geovanny Vera's avatar Geovanny Vera

Schedule widget with API calls done

parent 54ec0503
......@@ -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="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)
+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=Gamepad_FaceButton_Bottom)
+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=MotionController_Left_Grip1)
+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="UseAbility3",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Three)
+ActionMappings=(ActionName="UseAbility4",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Four)
......@@ -234,6 +204,36 @@ DoubleClickTime=0.200000
+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="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=S)
+AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=Up)
......
......@@ -16,7 +16,7 @@ async function main(){
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();
// console.log(data);
......
......@@ -23,13 +23,12 @@ UHttpService* UHttpService::GetHttp() {
return this;
}
void UHttpService::SetAuthToken(FString token) {
AuthToken = "Bearer ";
AuthToken.Append(token);
}
void UHttpService::SetTimeout(float Timeout) {
if (this == NULL) {
UE_LOG(LogTemp, Log, TEXT("TU PUTA MADRE"));
}
else if(this->Http == NULL) {
UE_LOG(LogTemp, Log, TEXT("LA TUYA"));
}
Http->SetHttpTimeout(Timeout);
}
......@@ -79,3 +78,13 @@ TSharedRef<IHttpRequest> UHttpService::GetRequest(FString Subroute) {
return Request;
}
TSharedRef<IHttpRequest> UHttpService::AuthPostRequest(FString Subroute, FString ContentJsonString) {
TSharedRef<IHttpRequest> Request = PostRequest(Subroute, ContentJsonString);
Request->SetHeader("Authorization", AuthToken);
}
TSharedRef<IHttpRequest> UHttpService::AuthGetRequest(FString Subroute) {
TSharedRef<IHttpRequest> Request = GetRequest(Subroute);
Request->SetHeader("Authorization", AuthToken);
}
\ No newline at end of file
......@@ -14,6 +14,7 @@ UHttpService* UVRCGameInstance::GetHttpService() {
void UVRCGameInstance::SetUserToken(FString token) {
User.Token = token;
Http->SetAuthToken(token);
}
FString UVRCGameInstance::GetUserToken() {
......
......@@ -19,21 +19,21 @@ 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->GetRequest("instances/join-server");
TSharedRef<IHttpRequest> Request = Http->AuthGetRequest("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");
//FString url = FString(VRCAPIPath + "instances/join-server");
Request->SetURL(url);
//Request->SetURL(url);
Request->ProcessRequest();
}
......@@ -68,19 +68,17 @@ void AVRCPlayerController::ConnectToMeeting(int32 MeetingId) {
UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance());
Http = GameInstance->GetHttpService();
FString token = GameInstance->GetUserToken();
Http->SetTimeout(20.0f);
TSharedRef<IHttpRequest> Request = Http->GetRequest("instances/join-classroom/123");
FString url = "http://localhost:1337/instances/join-classroom/";
url.AppendInt(MeetingId);
Request->SetURL(url);
FString SubRoute = "instances/join-classroom/";
SubRoute.AppendInt(MeetingId);
TSharedRef<IHttpRequest> Request = Http->AuthGetRequest(SubRoute);
//FString url = "http://localhost:1337/instances/join-classroom/";
//url.AppendInt(MeetingId);
//Request->SetURL(url);
Request->SetHeader("Accepts", TEXT("application/json"));
Request->OnProcessRequestComplete().BindUObject(this, &AVRCPlayerController::OnConnectToMeetingResponseRecieved);
FString auth = "Bearer ";
auth.Append(token);
Request->SetHeader("Authorization", auth);
Request->ProcessRequest();
}
......
......@@ -10,20 +10,20 @@ void UVRCScheduleWidget::GetMeetings() {
UVRCGameInstance* GameInstance = Cast<UVRCGameInstance>(GetWorld()->GetGameInstance());
Http = GameInstance->GetHttpService();
FString token = GameInstance->GetUserToken();
//FString token = GameInstance->GetUserToken();
Http->SetTimeout(20.0f);
TSharedRef<IHttpRequest> Request = Http->GetRequest("instances/join-classroom/123");
Request->SetURL(FString("http://localhost:1337/users/meetings"));
TSharedRef<IHttpRequest> Request = Http->AuthGetRequest("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();
Request->ProcessRequest();
//Testy();
}
void UVRCScheduleWidget::Testy() {
......@@ -42,27 +42,18 @@ void UVRCScheduleWidget::Testy() {
}
void UVRCScheduleWidget::OnGetMeetingsResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) {
FString asd = "[{\"id\":34,\"map_id\":1,\"name\":\"CSC123\",\"password\":\"angry\",\"repeating\":0,\"active\":0,\"creator_id\":1}]";
if (Http->ResponseIsValid(Response, bWasSuccessful)) {
TSharedPtr<FJsonObject> JsonObject;
TArray<FMeetingInfo> responseMeetings;
TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Response->GetContentAsString());
FString dsa = Response->GetContentAsString();
//UE_LOG(LogTemp, Log, TEXT("Response: %s"), &dsa);
//if (FJsonSerializer::Deserialize(Reader, JsonObject))
//{
if(FJsonObjectConverter::JsonArrayStringToUStruct(asd, &responseMeetings, 0, 0)){
/*FString IP = JsonObject->GetStringField("ip");
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);*/
FString content = FString(Response->GetContentAsString());
if (FJsonObjectConverter::JsonArrayStringToUStruct(content, &responseMeetings, 0, 0)) {
meetings = responseMeetings;
UE_LOG(LogTemp, Log, TEXT("Meetings found: %d", meetings.Num));
//NotifyGetMeetings();
//UE_LOG(LogTemp, Log, TEXT("Response: %s"), Response->GetContentAsString());
NotifyGetMeetings();
}
else {
UE_LOG(LogTemp, Error, TEXT("GetMeetings returned no data!"));
UE_LOG(LogTemp, Log, TEXT("No meetings found"));
}
}
else {
......
......@@ -15,7 +15,7 @@ class VRCLASSROOM_API UHttpService : public UObject
GENERATED_BODY()
FHttpModule* Http;
FString AuthToken = "";
public:
......@@ -25,6 +25,8 @@ public:
UHttpService* GetHttp();
void SetAuthToken(FString token);
void SetTimeout(float Timeout);
bool ResponseIsValid(FHttpResponsePtr Response, bool bWasSuccessful);
......@@ -36,4 +38,8 @@ public:
TSharedRef<IHttpRequest> PostRequest(FString Subroute, FString ContentJsonString);
TSharedRef<IHttpRequest> GetRequest(FString Subroute);
TSharedRef<IHttpRequest> AuthPostRequest(FString Subroute, FString ContentJsonString);
TSharedRef<IHttpRequest> AuthGetRequest(FString Subroute);
};
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