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


Java HttpRequest.setTimeOut方法代码示例

本文整理汇总了Java中com.badlogic.gdx.Net.HttpRequest.setTimeOut方法的典型用法代码示例。如果您正苦于以下问题:Java HttpRequest.setTimeOut方法的具体用法?Java HttpRequest.setTimeOut怎么用?Java HttpRequest.setTimeOut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.Net.HttpRequest的用法示例。


在下文中一共展示了HttpRequest.setTimeOut方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: urlCheck

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

示例2: sendRequest

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

示例3: getTAPData

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

示例4: sendHttpGetRequest

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


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