Hey guys!
I’d like to post highscores from my game through HTTP. I understand this can be done easily with LibGDX’s Net-module, if I provide an InputStream with the data I want transferred.
I’m not very good working with streams over the network, so I don’t know the pitfalls and what I need to be wary about.
How would I go about sending a JSON object (from memory), to my webserver, using POST, and LibGDX?
Thanks guys.
EDIT:
HttpRequest httpPost = new HttpRequest(HttpMethods.Post);
httpPost.setUrl("http://highscore-server.net/highscore-accepting-script.php");
httpPost.setContent(stream, length);
Gdx.net.sendHttpRequest (httpPost, new HttpResponseListener() {
public void handleHttpResponse(HttpResponse httpResponse) {
status = httpResponse.getResultAsString();
}
public void failed(Throwable t) {
status = "failed";
}
});
This as far as I can get, code-wise. I don’t know what to do for the InputStream.