Commit 1510f23a authored by Geovanny Vera's avatar Geovanny Vera

Some cleanup

parent cea436ce
...@@ -7,7 +7,7 @@ const router = new Router(); ...@@ -7,7 +7,7 @@ const router = new Router();
router.post('/', (ctx, next) => { router.post('/', (ctx, next) => {
const body = ctx.request.body; const body = ctx.request.body;
console.log(`Server ${body.name}`); console.log(`Server ${body.name}`);
const sub = spawn(CONFIG.UE4_PATH, [CONFIG.PROJECT_PATH, `TestServer?listen`, '-server', '-log', '-nosteam', '-messaging', `-port=${body.port}`], { const sub = spawn(CONFIG.UE4_PATH, [CONFIG.PROJECT_PATH, `${body.name}?listen`, '-server', '-log', '-nosteam', '-messaging', `-port=${body.port}`], {
detached: true, detached: true,
stdio: 'ignore' stdio: 'ignore'
}); });
...@@ -20,7 +20,7 @@ router.post('/', (ctx, next) => { ...@@ -20,7 +20,7 @@ router.post('/', (ctx, next) => {
router.post('/classroom', (ctx, next) => { router.post('/classroom', (ctx, next) => {
const body = ctx.request.body; const body = ctx.request.body;
console.log(`Classroom ${body.name}`); console.log(`Classroom ${body.name}`);
const sub = spawn(CONFIG.UE4_PATH, [CONFIG.PROJECT_PATH, `TestClassroom?listen`, '-server', '-log', '-nosteam', '-messaging', `-port=${body.port}`], { const sub = spawn(CONFIG.UE4_PATH, [CONFIG.PROJECT_PATH, `${body.name}?listen`, '-server', '-log', '-nosteam', '-messaging', `-port=${body.port}`], {
detached: true, detached: true,
stdio: 'ignore' stdio: 'ignore'
}); });
......
...@@ -22,27 +22,19 @@ void AVRCPlayerController::ConnectToCampus() { ...@@ -22,27 +22,19 @@ void AVRCPlayerController::ConnectToCampus() {
} }
Http->SetTimeout(TravelTimeout); Http->SetTimeout(TravelTimeout);
TSharedRef<IHttpRequest> Request = Http->PostRequest("dsa", "asd"); TSharedRef<IHttpRequest> Request = Http->GetRequest("instances/join-server");
Request->OnProcessRequestComplete().BindUObject(this, &AVRCPlayerController::OnConnectToCampusResponseRecieved); Request->OnProcessRequestComplete().BindUObject(this, &AVRCPlayerController::OnConnectToCampusResponseRecieved);
Request->SetVerb("POST"); Request->SetHeader("Accepts", TEXT("application/json"));
Request->SetHeader(TEXT("User-Agent"), "X-UnrealEngine-Agent");
Request->SetHeader("Content-Type", TEXT("application/json"));
Request->SetHeader(TEXT("Accepts"), TEXT("application/json"));
FString url = FString(VRCAPIPath + "instances/join-server"); FString url = FString(VRCAPIPath + "instances/join-server");
TArray<FStringFormatArg> FormatParams;
FormatParams.Add(TEXT("Geo"));
FormatParams.Add(TEXT("123"));
FString PostParameters = FString::Format(TEXT("{\"Username\": \"{0}\", \"Pass\": \"{1}\"}"), FormatParams);
Request->SetURL(url); Request->SetURL(url);
Request->SetContentAsString(PostParameters);
Request->ProcessRequest(); Request->ProcessRequest();
} }
void AVRCPlayerController::OnConnectToCampusResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) void AVRCPlayerController::OnConnectToCampusResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
{ {
if (bWasSuccessful) { if (Http->ResponseIsValid(Response, bWasSuccessful)) {
TSharedPtr<FJsonObject> JsonObject; TSharedPtr<FJsonObject> JsonObject;
TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Response->GetContentAsString()); TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Response->GetContentAsString());
...@@ -59,7 +51,6 @@ void AVRCPlayerController::OnConnectToCampusResponseRecieved(FHttpRequestPtr Req ...@@ -59,7 +51,6 @@ void AVRCPlayerController::OnConnectToCampusResponseRecieved(FHttpRequestPtr Req
} }
else { else {
UE_LOG(LogTemp, Error, TEXT("OnConnectToCampus Server returned no data!")); UE_LOG(LogTemp, Error, TEXT("OnConnectToCampus Server returned no data!"));
} }
} }
else { else {
...@@ -77,11 +68,9 @@ void AVRCPlayerController::ConnectToMeeting(FString MeetingId) { ...@@ -77,11 +68,9 @@ void AVRCPlayerController::ConnectToMeeting(FString MeetingId) {
MeetingId.TrimStartAndEndInline(); MeetingId.TrimStartAndEndInline();
FString PostParameters = FString(TEXT("{\"meetingId\":\"123\"}")); TSharedRef<IHttpRequest> Request = Http->GetRequest("instances/join-classroom/123");
TSharedRef<IHttpRequest> Request = Http->GetRequest("meeting/connect");
Request->SetURL(FString("http://localhost:1337/instances/join-classroom/123")); Request->SetURL(FString("http://localhost:1337/instances/join-classroom/123"));
Request->SetHeader("Content-Type", TEXT("application/json")); Request->SetHeader("Accepts", TEXT("application/json"));
Request->OnProcessRequestComplete().BindUObject(this, &AVRCPlayerController::OnConnectToMeetingResponseRecieved); Request->OnProcessRequestComplete().BindUObject(this, &AVRCPlayerController::OnConnectToMeetingResponseRecieved);
Request->ProcessRequest(); Request->ProcessRequest();
...@@ -89,7 +78,6 @@ void AVRCPlayerController::ConnectToMeeting(FString MeetingId) { ...@@ -89,7 +78,6 @@ void AVRCPlayerController::ConnectToMeeting(FString MeetingId) {
void AVRCPlayerController::OnConnectToMeetingResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) { void AVRCPlayerController::OnConnectToMeetingResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) {
FString content = *Response->GetContentAsString(); FString content = *Response->GetContentAsString();
UE_LOG(LogTemp, Log, TEXT("asdsad"));
if(Http->ResponseIsValid(Response, bWasSuccessful)){ if(Http->ResponseIsValid(Response, bWasSuccessful)){
UE_LOG(LogTemp, Log, TEXT("Connecting to meeting")); UE_LOG(LogTemp, Log, TEXT("Connecting to meeting"));
...@@ -107,7 +95,7 @@ void AVRCPlayerController::OnConnectToMeetingResponseRecieved(FHttpRequestPtr Re ...@@ -107,7 +95,7 @@ void AVRCPlayerController::OnConnectToMeetingResponseRecieved(FHttpRequestPtr Re
TravelToMap(URL, false); TravelToMap(URL, false);
} }
else { else {
UE_LOG(LogTemp, Error, TEXT("OnConnectToCampus Server returned no data!")); UE_LOG(LogTemp, Error, TEXT("OnConnectToMeeting Server returned no data!"));
} }
}else{ }else{
......
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