use of com.badlogic.gdx.net.HttpRequestBuilder in project Mindustry by Anuken.
the class Net method http.
public static void http(String url, String method, Consumer<String> listener, Consumer<Throwable> failure) {
HttpRequest req = new HttpRequestBuilder().newRequest().method(method).url(url).build();
Gdx.net.sendHttpRequest(req, new HttpResponseListener() {
@Override
public void handleHttpResponse(HttpResponse httpResponse) {
listener.accept(httpResponse.getResultAsString());
}
@Override
public void failed(Throwable t) {
failure.accept(t);
}
@Override
public void cancelled() {
}
});
}
use of com.badlogic.gdx.net.HttpRequestBuilder in project skin-composer by raeleus.
the class Main method checkForUpdates.
public static void checkForUpdates(Main main) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
HttpRequestBuilder requestBuilder = new HttpRequestBuilder();
HttpRequest httpRequest = requestBuilder.newRequest().method(HttpMethods.GET).url("https://raw.githubusercontent.com/raeleus/skin-composer/master/version").build();
Gdx.net.sendHttpRequest(httpRequest, new Net.HttpResponseListener() {
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
newVersion = httpResponse.getResultAsString();
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
main.rootTable.fire(new RootTable.RootTableEvent(RootTable.RootTableEnum.CHECK_FOR_UPDATES_COMPLETE));
}
});
}
@Override
public void failed(Throwable t) {
newVersion = VERSION;
}
@Override
public void cancelled() {
newVersion = VERSION;
}
});
}
});
thread.start();
}
Aggregations