当前位置: 首页>>代码示例>>Java>>正文


Java HttpResponse类代码示例

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


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


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