A modded EditSaber for making beat saber maps.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.9 KiB

5 years ago
  1. // Fill out your copyright notice in the Description page of Project Settings.
  2. #include "MMServerRequest.h"
  3. #include "BeatSaberEditor.h"
  4. #include "UnrealString.h"
  5. UMMServerRequest::UMMServerRequest():
  6. uploadFile(TEXT(""))
  7. , output(TEXT(""))
  8. {
  9. }
  10. UMMServerRequest::~UMMServerRequest()
  11. {
  12. }
  13. UMMServerRequest* UMMServerRequest::MakeRequester()
  14. {
  15. UMMServerRequest* Requester = NewObject<UMMServerRequest>();
  16. return Requester;
  17. }
  18. void UMMServerRequest::SendSong()
  19. {
  20. FHttpModule* Http = &FHttpModule::Get();
  21. TSharedRef<IHttpRequest> Request = Http->CreateRequest();
  22. //This is the url on which to process the request
  23. TArray<uint8> UpFileRawData;
  24. Request->SetURL("http://5.196.73.28/useragent/");
  25. Request->SetVerb("POST");
  26. Request->SetHeader(TEXT("User-Agent"), "MediocreMapper");
  27. Request->SetHeader("Content-Type", TEXT("text/plain"));
  28. Request->OnProcessRequestComplete().BindUObject(this, &UMMServerRequest::OnResponseReceived);
  29. Request->ProcessRequest();
  30. AddToRoot();
  31. }
  32. void UMMServerRequest::OnResponseReceived(FHttpRequestPtr Request, FHttpResponsePtr Response, bool bWasSuccessful)
  33. {
  34. RemoveFromRoot();
  35. //output = BytesToString(Response->GetContent().GetData(), Response->GetContentLength());
  36. ////Create a pointer to hold the json serialized data
  37. //TSharedPtr<FJsonObject> JsonObject;
  38. ////Create a reader pointer to read the json data
  39. //TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Response->GetContentAsString());
  40. ////Deserialize the json data given Reader and the actual object to deserialize
  41. //if (FJsonSerializer::Deserialize(Reader, JsonObject))
  42. //{
  43. // //Get the value of the json object by field name
  44. // int32 recievedInt = JsonObject->GetIntegerField("customInt");
  45. // //Output it to the engine
  46. // GEngine->AddOnScreenDebugMessage(1, 2.0f, FColor::Green, FString::FromInt(recievedInt));
  47. //}
  48. }
  49. FString UMMServerRequest::getOutput()
  50. {
  51. return UMMServerRequest::output;
  52. }