Sending an FString Via Sockets

So a member of my team has asked me to write a function that sends an FString to a PHP file on our server to authenticate users before they can join our UE4 multiplayer server. I’ve been combing through the header files and I’m no longer entirely sure that I’m approaching this the right way.

I’ve been using the TcpSocketBuilder to open a socket on an arbitrary port and then the BitReader and BitWriter to serialize the data into a buffer that can be sent to the server.

This has presented two problems:

  1. The PHP file is expecting a string (specifically a POST request), and this function would be sending serialized data that the php file doesn’t understand.

  2. the sockets opened point to only an IPv4Address. the php file is located at [IPv4Address].authuser.php.

does anyone have any suggestions for an easier way to go about this, or where i’m going wrong in my approach?

thank you!
m

We have an HTTP interface that can send anything to a backend server, with RESTful calls or otherwise.

You just setup the header, verb, add a payload as string and send the request.

For example…

TSharedRef HttpRequest = FHttpModule::Get().CreateRequest();

HttpRequest->OnProcessRequestComplete() = ResponseDelegate;
HttpRequest->SetURL(URL);
HttpRequest->SetHeader(TEXT("Content-Type"), TEXT("application/json"));
HttpRequest->SetHeader(TEXT("User-Agent"), GetUserAgent());
HttpRequest->SetHeader(TEXT("Authorization"), UserAuth);
HttpRequest->SetVerb(Verb);
HttpRequest->SetContentAsString(JsonRequestStr);
HttpRequest->ProcessRequest();

oh man, that makes this SO much easier, thank you!