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

Some cleanup

parent cea436ce
......@@ -7,7 +7,7 @@ const router = new Router();
router.post('/', (ctx, next) => {
const body = ctx.request.body;
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,
stdio: 'ignore'
});
......@@ -20,7 +20,7 @@ router.post('/', (ctx, next) => {
router.post('/classroom', (ctx, next) => {
const body = ctx.request.body;
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,
stdio: 'ignore'
});
......
......@@ -22,27 +22,19 @@ void AVRCPlayerController::ConnectToCampus() {
}
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->SetVerb("POST");
Request->SetHeader(TEXT("User-Agent"), "X-UnrealEngine-Agent");
Request->SetHeader("Content-Type", TEXT("application/json"));
Request->SetHeader(TEXT("Accepts"), TEXT("application/json"));
Request->SetHeader("Accepts", TEXT("application/json"));
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->SetContentAsString(PostParameters);
Request->ProcessRequest();
}
void AVRCPlayerController::OnConnectToCampusResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
{
if (bWasSuccessful) {
if (Http->ResponseIsValid(Response, bWasSuccessful)) {
TSharedPtr<FJsonObject> JsonObject;
TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Response->GetContentAsString());
......@@ -59,7 +51,6 @@ void AVRCPlayerController::OnConnectToCampusResponseRecieved(FHttpRequestPtr Req
}
else {
UE_LOG(LogTemp, Error, TEXT("OnConnectToCampus Server returned no data!"));
}
}
else {
......@@ -77,11 +68,9 @@ void AVRCPlayerController::ConnectToMeeting(FString MeetingId) {
MeetingId.TrimStartAndEndInline();
FString PostParameters = FString(TEXT("{\"meetingId\":\"123\"}"));
TSharedRef<IHttpRequest> Request = Http->GetRequest("meeting/connect");
TSharedRef<IHttpRequest> Request = Http->GetRequest("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->ProcessRequest();
......@@ -89,7 +78,6 @@ void AVRCPlayerController::ConnectToMeeting(FString MeetingId) {
void AVRCPlayerController::OnConnectToMeetingResponseRecieved(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful) {
FString content = *Response->GetContentAsString();
UE_LOG(LogTemp, Log, TEXT("asdsad"));
if(Http->ResponseIsValid(Response, bWasSuccessful)){
UE_LOG(LogTemp, Log, TEXT("Connecting to meeting"));
......@@ -107,7 +95,7 @@ void AVRCPlayerController::OnConnectToMeetingResponseRecieved(FHttpRequestPtr Re
TravelToMap(URL, false);
}
else {
UE_LOG(LogTemp, Error, TEXT("OnConnectToCampus Server returned no data!"));
UE_LOG(LogTemp, Error, TEXT("OnConnectToMeeting Server returned no data!"));
}
}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