• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java HttpResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.badlogic.gdx.Net.HttpResponse的典型用法代码示例。如果您正苦于以下问题:Java HttpResponse类的具体用法?Java HttpResponse怎么用?Java HttpResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HttpResponse类属于com.badlogic.gdx.Net包,在下文中一共展示了HttpResponse类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: create

import com.badlogic.gdx.Net.HttpResponse; //导入依赖的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: urlCheck

import com.badlogic.gdx.Net.HttpResponse; //导入依赖的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


示例3: handleHttpResponse

import com.badlogic.gdx.Net.HttpResponse; //导入依赖的package包/类
@Override
public void handleHttpResponse(HttpResponse httpResponse)
{
	downloaders.add(this);

	internalToAbsolute(".tmp/").file().mkdir();
	temp.parent().mkdirs();
	try (ReadableByteChannel rbc = Channels.newChannel(httpResponse.getResultAsStream());
			FileOutputStream fos = new FileOutputStream(out))
	{
		fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
		tempFiles.put(filename, temp);
		Gdx.app.log("Download", "Finished downloading " + filename);
	} catch (IOException e)
	{
		e.printStackTrace();
		out.delete();
	}

	downloaders.removeValue(this, false);

	success.run();
}
 
开发者ID:nhydock,项目名称:Boogie,代码行数:24,代码来源:DownloadUtils.java


示例4: ga

import com.badlogic.gdx.Net.HttpResponse; //导入依赖的package包/类
/**
 * Sends the given payload to backend
 */
private void ga(String payload) {
	HttpRequest request = new HttpRequest("POST");
	request.setContent("v=1&tid=" + tracker + "&an=eAdventureDesktop&av="
			+ version + "&cid=" + cid + "&" + payload);
	Gdx.net.sendHttpRequest(request, new HttpResponseListener() {
		@Override
		public void handleHttpResponse(HttpResponse httpResponse) {

		}

		@Override
		public void failed(Throwable t) {

		}

		@Override
		public void cancelled() {

		}
	});
}
 
开发者ID:e-ucm,项目名称:ead,代码行数:25,代码来源:GATracker.java


示例5: GET

import com.badlogic.gdx.Net.HttpResponse; //导入依赖的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


示例6: sendRequest

import com.badlogic.gdx.Net.HttpResponse; //导入依赖的package包/类
private void sendRequest(final TwitterRequest twitterRequest, final TwitterResponseListener listener) {

		HttpRequestBuilder requestBuilder = new HttpRequestBuilder();
		HttpRequest httpRequest = requestBuilder.newRequest().method(twitterRequest.getRequestType().name()).url(twitterRequest.getUrl()).build();

		// System.out.println(twitterRequest.build().getHeader());
		twitterRequest.build();

		httpRequest.setHeader("Authorization", twitterRequest.getHeader());
		httpRequest.setContent(twitterRequest.getData());
		httpRequest.setTimeOut(config.TWITTER_REQUEST_TIMEOUT);
		Gdx.net.sendHttpRequest(httpRequest, new HttpResponseListener() {

			@Override
			public void handleHttpResponse(HttpResponse httpResponse) {
				if (httpResponse.getStatus().getStatusCode() == 200) {
					listener.success(httpResponse.getResultAsString());
				} else {
					listener.apiError(httpResponse.getStatus(), httpResponse.getResultAsString());
				}
			}

			@Override
			public void failed(Throwable t) {
				listener.httpError(t);

			}

			@Override
			public void cancelled() {
				listener.cancelled();
			}
		});

	}
 
开发者ID:TomGrill,项目名称:gdx-twitter,代码行数:36,代码来源:TwitterAPI.java


示例7: handleHttpResponse

import com.badlogic.gdx.Net.HttpResponse; //导入依赖的package包/类
@Override
public void handleHttpResponse(HttpResponse httpResponse) {
	String result = httpResponse.getResultAsString();
	rs = json.fromJson(RemoteScore.class, result);
	
	Gdx.app.debug("Score response", result);
	Gdx.app.debug("Remote score got", 
			"Date : " + rs.getPlayDate() + 
			" / Player name : " + rs.getPlayerName() +
			" / Score : " + rs.getScore());
}
 
开发者ID:gcleenew,项目名称:RottenCave,代码行数:12,代码来源:GetListener.java


示例8: handleHttpResponse

import com.badlogic.gdx.Net.HttpResponse; //导入依赖的package包/类
@Override
public void handleHttpResponse(HttpResponse httpResponse) {
	HttpStatus status = httpResponse.getStatus();
	
	if (status.getStatusCode() >= 200 && status.getStatusCode() < 300) {
		String result = httpResponse.getResultAsString();
		
		Gdx.app.debug("Score response", "ScoresList recieved !");
		Gdx.app.debug("Score response", result);
		
		@SuppressWarnings("unchecked")
		LinkedList<JsonValue> list = json.fromJson(LinkedList.class, result);
		
		if (list != null) {
			for (JsonValue jsonValue : list) {
				remoteScores.add(json.readValue(RemoteScore.class, jsonValue));
			}
			
			Gdx.app.debug("Remote list size", ""+remoteScores.size());
		} else {
			Gdx.app.debug("Score response", "No data to process !");
		}
		
		Gdx.app.debug("Score response", "Process data");
		processor.processList(remoteScores);
	} else {
		Gdx.app.debug("Score response", "http error, code : "+status.getStatusCode());
		showDialog();
	}
}
 
开发者ID:gcleenew,项目名称:RottenCave,代码行数:31,代码来源:ListListener.java


示例9: handleHttpResponse

import com.badlogic.gdx.Net.HttpResponse; //导入依赖的package包/类
@Override
public void handleHttpResponse(HttpResponse httpResponse) {

	if (cookieMgr != null) {
		List<String> cookieStrings = httpResponse.getHeaders().get("Set-Cookie");
		if (cookieStrings != null) {
			for (String cookie : cookieStrings) {
				cookieMgr.registerSetCookieHeader(cookie, sourceUri);
			}
			cookieMgr.save();
		}
	}
	listener.handleHttpResponse(httpResponse);
}
 
开发者ID:failcoDave,项目名称:gdx-http,代码行数:15,代码来源:DefaultHttpClient.java


示例10: create

import com.badlogic.gdx.Net.HttpResponse; //导入依赖的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


示例11: setText

import com.badlogic.gdx.Net.HttpResponse; //导入依赖的package包/类
void setText (HttpResponse httpResponse) {
	final String newText = httpResponse.getResultAsString();
	Gdx.app.postRunnable(new Runnable() {
		public void run () {
			text = newText;
		}
	});
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:9,代码来源:NetAPITest.java


示例12: getTAPData

import com.badlogic.gdx.Net.HttpResponse; //导入依赖的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


示例13: loadClientId

import com.badlogic.gdx.Net.HttpResponse; //导入依赖的package包/类
/**
 * Loads the client identifier from preferences. If it does not exists,
 * obtains one from bugr.
 */
protected void loadClientId() {
	String clientId = controller.getPreferences().getString(
			Preferences.CLIENT_ID);
	if ("".equals(clientId) || clientId == null) {
		HttpRequest request = new HttpRequest("POST");
		request.setUrl(bugrURL + ACTIVATE_PATH);
		// Obtain an unique id
		Gdx.net.sendHttpRequest(request, new HttpResponseListener() {
			@Override
			public void handleHttpResponse(HttpResponse httpResponse) {
				if (httpResponse.getStatus().getStatusCode() == 200) {
					cid = httpResponse.getResultAsString();
					controller.getPreferences().putString(
							Preferences.CLIENT_ID, cid);
					// Start session with recently acquired cid
					startSession();
				} else {
					Gdx.app.error("Tracker",
							"Impossible to activate this installation. Server said:\n"
									+ httpResponse.getResultAsString());
				}
			}

			@Override
			public void failed(Throwable throwable) {
				Gdx.app.error("Tracker",
						"Impossible to activate this installation.",
						throwable);
			}

			@Override
			public void cancelled() {

			}
		});
	} else {
		this.cid = clientId;
	}
}
 
开发者ID:e-ucm,项目名称:ead,代码行数:44,代码来源:Tracker.java


示例14: POST

import com.badlogic.gdx.Net.HttpResponse; //导入依赖的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


示例15: handleHttpResponse

import com.badlogic.gdx.Net.HttpResponse; //导入依赖的package包/类
@Override
public void handleHttpResponse(HttpResponse httpResponse) {
	Gdx.app.debug("Score response", httpResponse.getResultAsString());
}
 
开发者ID:gcleenew,项目名称:RottenCave,代码行数:5,代码来源:JsonListener.java


示例16: handleHttpResponse

import com.badlogic.gdx.Net.HttpResponse; //导入依赖的package包/类
@Override
public void handleHttpResponse (HttpResponse httpResponse) {

	final int statusCode = httpResponse.getStatus().getStatusCode();
	// We are not in main thread right now so we need to post to main thread for ui updates
	Gdx.app.postRunnable(new Runnable() {
		@Override
		public void run () {
			statusLabel.setText("HTTP Request status: " + statusCode);
			setButtonDisabled(false);
		}
	});

	if (statusCode != 200) {
		Gdx.app.log("NetAPITest", "An error ocurred since statusCode is not OK");
		setText(httpResponse);
		return;
	}

	if (clickedButton == btnDownloadImage) {
		final byte[] rawImageBytes = httpResponse.getResult();
		Gdx.app.postRunnable(new Runnable() {
			public void run () {
				Pixmap pixmap = new Pixmap(rawImageBytes, 0, rawImageBytes.length);
				texture = new Texture(pixmap);
			}
		});

	} else if (clickedButton == btnDownloadLarge) {
		Gdx.app.postRunnable(new Runnable() {
			public void run () {
				text = "Retrieving large file...";
			}
		});
		final byte[] rawFileBytes = httpResponse.getResult();
		Gdx.app.postRunnable(new Runnable() {
			public void run () {
				text = "Retrieved large file: " + rawFileBytes.length;
			}
		});

	} else {
		setText(httpResponse);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:46,代码来源:NetAPITest.java


示例17: getJsonList

import com.badlogic.gdx.Net.HttpResponse; //导入依赖的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


示例18: call

import com.badlogic.gdx.Net.HttpResponse; //导入依赖的package包/类
@Override
public Object call() throws Exception {
	// Try to download update.json. If updateURL is not present, disable
	// the update system
	if (releaseInfo.getUpdateURL() != null) {
		HttpRequest request = new HttpRequest("GET");
		request.setUrl(releaseInfo.getUpdateURL());
		Gdx.app.debug(LOG_TAG,
				"Trying to retrieve update.json from url:"
						+ releaseInfo.getUpdateURL());
		Gdx.net.sendHttpRequest(request, new HttpResponseListener() {
			@Override
			public void handleHttpResponse(HttpResponse httpResponse) {

				if (httpResponse.getStatus().getStatusCode() == 200) {
					String data = httpResponse.getResultAsString();
					Gdx.app.debug(LOG_TAG,
							"Update.json fetched and read: " + data);
					try {
						UpdateInfo updateInfo = controller
								.getApplicationAssets().fromJson(
										UpdateInfo.class, data);

						if (updateInfo != null) {
							checkUpdateNeeded(updateInfo);
						}
					} catch (SerializationException e) {
						Gdx.app.error(
								LOG_TAG,
								"An error occurred while reading update.json from "
										+ releaseInfo.getUpdateURL()
										+ ". The update system will be disabled.",
								e);
						setDone();
					}
				}
			}

			@Override
			public void failed(Throwable t) {
				Gdx.app.debug(
						LOG_TAG,
						"Error fetching update.json. Updater will be disabled",
						t);
				setDone();
			}

			@Override
			public void cancelled() {

			}
		});
	} else {
		Gdx.app.debug(LOG_TAG,
				"The update.json url is null. The update system will be disabled.");
		setDone();
	}

	return null;
}
 
开发者ID:e-ucm,项目名称:ead,代码行数:61,代码来源:Updater.java



注:本文中的com.badlogic.gdx.Net.HttpResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WriterConfig类代码示例发布时间:2022-05-22
下一篇:
Java IfNode类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap