本文整理汇总了Java中com.badlogic.gdx.Net.HttpMethods类的典型用法代码示例。如果您正苦于以下问题:Java HttpMethods类的具体用法?Java HttpMethods怎么用?Java HttpMethods使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpMethods类属于com.badlogic.gdx.Net包,在下文中一共展示了HttpMethods类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: create
import com.badlogic.gdx.Net.HttpMethods; //导入依赖的package包/类
@Override
public void create () {
HttpRequest request = new HttpRequest(HttpMethods.GET);
request.setUrl("http://libgdx.badlogicgames.com/nightlies/dist/AUTHORS");
Gdx.net.sendHttpRequest(request, new HttpResponseListener() {
@Override
public void handleHttpResponse (HttpResponse httpResponse) {
Gdx.app.log("HttpRequestExample", "response: " + httpResponse.getResultAsString());
}
@Override
public void failed (Throwable t) {
Gdx.app.error("HttpRequestExample", "something went wrong", t);
}
@Override
public void cancelled () {
Gdx.app.log("HttpRequestExample", "cancelled");
}
});
}
开发者ID:basherone,项目名称:libgdxcn,代码行数:22,代码来源:HttpRequestExample.java
示例2: sendRequest
import com.badlogic.gdx.Net.HttpMethods; //导入依赖的package包/类
protected void sendRequest(String method, Map<String, String> params, final NetworkListener listener){
HttpRequest httpPost = new HttpRequest(HttpMethods.POST);
httpPost.setUrl(website + method + ".php");
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");
httpPost.setContent(HttpParametersUtils.convertHttpParameters(params));
Gdx.net.sendHttpRequest (httpPost, new HttpResponseListener() {
public void handleHttpResponse(Net.HttpResponse httpResponse) {
String responce = new String(httpResponse.getResult());
String dat = decrypt(responce, ENC_KEY);
listener.finished(dat);
listener.length(dat.getBytes().length);
}
public void failed(Throwable t) {
listener.failed(t);
}
public void cancelled(){
}
});
}
开发者ID:Xemplar,项目名称:NerdShooter,代码行数:24,代码来源:NetworkHandle.java
示例3: urlCheck
import com.badlogic.gdx.Net.HttpMethods; //导入依赖的package包/类
private void urlCheck(final String url, final LinkListener listener) {
HttpRequest request = new HttpRequest(HttpMethods.GET);
request.setUrl(url);
request.setTimeOut(TIMEOUT_MS);
Gdx.net.sendHttpRequest(request, new HttpResponseListener() {
@Override
public void handleHttpResponse(HttpResponse httpResponse) {
if (httpResponse.getStatus().getStatusCode() == HttpStatus.SC_OK) {
listener.ok(url);
} else {
listener.ko(url);
}
}
@Override
public void failed(Throwable t) {
listener.ko(url);
}
@Override
public void cancelled() {
listener.ko(url);
}
});
}
开发者ID:langurmonkey,项目名称:gaiasky,代码行数:27,代码来源:DesktopNetworkChecker.java
示例4: GET
import com.badlogic.gdx.Net.HttpMethods; //导入依赖的package包/类
public void GET(String query) {
if (work)
return;
work = true;
HttpRequestBuilder requestBuilder = new HttpRequestBuilder();
HttpRequest request = requestBuilder.newRequest().url(urlString).timeout(timeout).content(query).method(HttpMethods.GET).build();
final WWW my = this;
Gdx.net.sendHttpRequest(request, new HttpResponseListener() {
public void handleHttpResponse(HttpResponse httpResponse) {
responseBytes = httpResponse.getResult();
// Gdx.app.log("WWW", "Response: " + responseBytes.length);
// Gdx.app.log("WWW", "Status: " + httpResponse.getStatus().getStatusCode());
work = false;
if (wwwResponseListener != null) {
Gdx.app.postRunnable(new Runnable() {
public void run() {
wwwResponseListener.httpResponseListener(my);
}
});
}
}
public void failed(Throwable t) {
Gdx.app.error(WWW.class.getSimpleName(), "failed: " + t);
work = false;
}
public void cancelled() {
Gdx.app.error(WWW.class.getSimpleName(), "cancelled");
work = false;
}
});
}
开发者ID:Radomiej,项目名称:JavityEngine,代码行数:38,代码来源:WWW.java
示例5: create
import com.badlogic.gdx.Net.HttpMethods; //导入依赖的package包/类
@Override
public void create () {
batch = new SpriteBatch();
HttpRequest request = new HttpRequest(HttpMethods.GET);
request.setUrl("https://www.google.at/images/srpr/logo11w.png");
Gdx.net.sendHttpRequest(request, new HttpResponseListener() {
@Override
public void handleHttpResponse (HttpResponse httpResponse) {
final byte[] bytes = httpResponse.getResult();
Gdx.app.postRunnable(new Runnable() {
@Override
public void run () {
Pixmap pixmap = new Pixmap(bytes, 0, bytes.length);
texture = new Texture(new PixmapTextureData(pixmap, pixmap.getFormat(), false, false, true));
}
});
}
@Override
public void failed (Throwable t) {
t.printStackTrace();
Gdx.app.log("EmptyDownloadTest", "Failed", t);
}
@Override
public void cancelled () {
Gdx.app.log("EmptyDownloadTest", "Cancelled");
}
});
}
开发者ID:basherone,项目名称:libgdxcn,代码行数:32,代码来源:DownloadTest.java
示例6: getTAPData
import com.badlogic.gdx.Net.HttpMethods; //导入依赖的package包/类
private String[][] getTAPData(String url, boolean hip, final String format, final GaiaDataListener listener) {
HttpRequest request = new HttpRequest(HttpMethods.GET);
request.setUrl(url);
request.setTimeOut(5000);
Gdx.net.sendHttpRequest(request, new HttpResponseListener() {
@Override
public void handleHttpResponse(HttpResponse httpResponse) {
if (httpResponse.getStatus().getStatusCode() == HttpStatus.SC_OK) {
// Ok
listener.ok(isToArray(httpResponse.getResultAsStream(), format), hip);
} else {
// Ko with code
listener.ko(httpResponse.getStatus().toString());
}
}
@Override
public void failed(Throwable t) {
// Failed
listener.ko();
}
@Override
public void cancelled() {
// Cancelled
listener.ko();
}
});
return null;
}
开发者ID:langurmonkey,项目名称:gaiasky,代码行数:34,代码来源:GaiaCatalogWindow.java
示例7: sendHttpGetRequest
import com.badlogic.gdx.Net.HttpMethods; //导入依赖的package包/类
@Override
public <T> T sendHttpGetRequest(String URL, Class<T> type)
throws IOException {
HttpRequest httpRequest = Pools.obtain(HttpRequest.class);
httpRequest.setMethod(Net.HttpMethods.GET);
httpRequest.setTimeOut(TIMEOUT);
httpRequest.setUrl(URL);
try {
return sendHttpRequest(httpRequest, type);
} finally {
Pools.free(httpRequest);
}
}
开发者ID:e-ucm,项目名称:ead,代码行数:14,代码来源:AbstractPlatform.java
示例8: POST
import com.badlogic.gdx.Net.HttpMethods; //导入依赖的package包/类
public void POST(Object form) {
if (work)
return;
work = true;
HttpRequestBuilder requestBuilder = new HttpRequestBuilder();
HttpRequest request = requestBuilder.newRequest().url(urlString).timeout(timeout).jsonContent(form).method(HttpMethods.POST)
.build();
final WWW my = this;
Gdx.net.sendHttpRequest(request, new HttpResponseListener() {
public void handleHttpResponse(final HttpResponse httpResponse) {
responseBytes = httpResponse.getResult();
// Gdx.app.log(WWW.class.getSimpleName(), "response bytes: " + responseBytes.length + " response string: "
// + httpResponse.getResultAsString() + " Code: " + httpResponse.getStatus().getStatusCode());
statusCode = httpResponse.getStatus().getStatusCode();
work = false;
if (wwwResponseListener != null) {
Gdx.app.postRunnable(new Runnable() {
public void run() {
wwwResponseListener.httpResponseListener(my);
}
});
}
}
public void failed(Throwable t) {
Gdx.app.error(WWW.class.getSimpleName(), "failed: " + t);
work = false;
}
public void cancelled() {
Gdx.app.error(WWW.class.getSimpleName(), "cancelled");
work = false;
}
});
}
开发者ID:Radomiej,项目名称:JavityEngine,代码行数:42,代码来源:WWW.java
示例9: getScoreById
import com.badlogic.gdx.Net.HttpMethods; //导入依赖的package包/类
public void getScoreById(HttpResponseListener responseListener, int id) {
String url = URL_BASE + "get/" + id;
HttpRequest request = requestBuilder.newRequest().method(HttpMethods.GET).url(url).build();
Gdx.net.sendHttpRequest(request, responseListener);
}
开发者ID:gcleenew,项目名称:RottenCave,代码行数:6,代码来源:ScoreRestClient.java
示例10: getScoresList
import com.badlogic.gdx.Net.HttpMethods; //导入依赖的package包/类
public void getScoresList(HttpResponseListener responseListener) {
String url = URL_BASE + "list";
HttpRequest request = requestBuilder.newRequest().method(HttpMethods.GET).url(url).build();
Gdx.net.sendHttpRequest(request, responseListener);
}
开发者ID:gcleenew,项目名称:RottenCave,代码行数:6,代码来源:ScoreRestClient.java
示例11: pushRemoteScore
import com.badlogic.gdx.Net.HttpMethods; //导入依赖的package包/类
public void pushRemoteScore(HttpResponseListener responseListener, RemoteScore score) {
String url = URL_BASE + "create";
Json json = new Json(OutputType.json);
HttpRequest request = requestBuilder.newRequest().method(HttpMethods.POST).url(url).build();
request.setHeader("Content-Type", "application/json");
request.setContent(json.toJson(score, RemoteScore.class));
Gdx.app.debug("Push remote score ", json.toJson(score));
Gdx.net.sendHttpRequest(request, responseListener);
}
开发者ID:gcleenew,项目名称:RottenCave,代码行数:11,代码来源:ScoreRestClient.java
示例12: getJsonList
import com.badlogic.gdx.Net.HttpMethods; //导入依赖的package包/类
public void getJsonList() {
HttpRequest httpRequest = new HttpRequest(HttpMethods.GET);
httpRequest.setUrl("http://24.222.27.154/highscores.json");
Gdx.net.sendHttpRequest(httpRequest, new HttpResponseListener() {
@Override
public void handleHttpResponse(HttpResponse httpResponse) {
result = httpResponse.getResultAsString();
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
grabHighScores();
createHighScores();
}
});
}
@Override
public void failed(Throwable t) {
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
createHighScores();
if (highScoreStage != null) {
Dialog dialog = new Dialog("Error", new Skin(
Gdx.files.internal("data/uiskin.json")));
dialog.text("Connection Error");
dialog.button("OK");
dialog.show(highScoreStage);
}
}
});
result = "";
}
@Override
public void cancelled() {
}
});
// long time = System.currentTimeMillis();
// while(result == null) {
// if(System.currentTimeMillis() - time > 5000) {
// break;
// }
// }
//
// return result;
}
开发者ID:MitchZinck,项目名称:BlockJump,代码行数:57,代码来源:GameScreen.java
注:本文中的com.badlogic.gdx.Net.HttpMethods类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论