• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java HttpParametersUtils类的典型用法和代码示例

java 1次浏览

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

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

示例1: buildRequest

点赞 3

import com.badlogic.gdx.net.HttpParametersUtils; //导入依赖的package包/类
protected Net.HttpRequest buildRequest(String component, Map<String, String> params) {
    String request = GJ_GATEWAY + component;
    request += HttpParametersUtils.convertHttpParameters(params);

    /* Generate signature */
    final String signature;
    try {
        signature = md5(request + gjAppPrivateKey);
    } catch (Exception e) {
        /* Do not leak 'gamePrivateKey' in log */
        Gdx.app.error(GAMESERVICE_ID, "Cannot honor request: " + request, e);
        return null;
    }
    /* Append signature */
    String complete = request;
    complete += "&";
    complete += "signature";
    complete += "=";
    complete += signature;

    final Net.HttpRequest http = new Net.HttpRequest();
    http.setMethod(Net.HttpMethods.GET);
    http.setUrl(complete);

    return http;
}
 

开发者ID:MrStahlfelge,
项目名称:gdx-gamesvcs,
代码行数:27,
代码来源:GameJoltClient.java

示例2: sendRequest

点赞 3

import com.badlogic.gdx.net.HttpParametersUtils; //导入依赖的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: call

点赞 2

import com.badlogic.gdx.net.HttpParametersUtils; //导入依赖的package包/类
@Override
public Void call() throws Exception {
    statsReporterVO = crateStatsRequestVO();
    try {
        Net.HttpRequest httpRequest = new Net.HttpRequest(Net.HttpMethods.GET);
        httpRequest.setUrl(url);
        httpRequest.setContent(HttpParametersUtils.convertHttpParameters(getParameters()));
        Gdx.net.sendHttpRequest(httpRequest, new StatsReporterHttpResponseListener());
        Gdx.app.debug(TAG, "httpRequest : " + httpRequest.getUrl());
    } catch (Exception e) {
        // no connection no cry
        e.printStackTrace();
    }
    return null;
}
 

开发者ID:UnderwaterApps,
项目名称:submarine,
代码行数:16,
代码来源:StatsReporter.java

示例4: makeRequest

点赞 2

import com.badlogic.gdx.net.HttpParametersUtils; //导入依赖的package包/类
public void makeRequest(final int idEnklave, final ManagerAssets manager){
    Preferences pref = Gdx.app.getPreferences("informationLog");
    String acces = pref.getString("accesstoken");
    HashMap parameters = new HashMap<String,String>();
    parameters.put("enklave_id",String.valueOf(idEnklave));
    HttpRequestBuilder builder = new HttpRequestBuilder();
    Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.GET).url(url + prof).build();
    request.setHeader("Authorization", "Bearer " + acces);
    request.setContent(HttpParametersUtils.convertHttpParameters(parameters));
    Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
        @Override
        public void handleHttpResponse(Net.HttpResponse httpResponse) {
            if(httpResponse.getStatus().getStatusCode()<300) {
                String s = httpResponse.getResultAsString();
                JSONObject json = new JSONObject(s);
                enklave.setBricks(json.getInt("nr_bricks"));
                if (json.getString("faction").contentEquals("null")) {
                    enklave.setFaction(0);
                } else {
                    enklave.setFaction(json.getInt("faction"));
                }
                enklave.setId(json.getInt("id"));
                enklave.setRooms(json.getInt("rooms"));
                enklave.setName(json.getString("name"));
                if(!json.isNull("created_by"))
                    enklave.setUsercreate(json.getJSONObject("created_by").getString("username"));
                enklave.setLatitude((float) json.getDouble("latitude"));
                enklave.setLongitude((float) json.getDouble("longitude"));
                enklave.setExtensions(json.getInt("extensions"));
                enklave.setTurrets(json.getInt("cells"));
                if(json.getString("status").contentEquals("InCombat")) {
                    enklave.setStatusCombat(true);
                    enklave.setShields(json.getInt("shield"));
                    enklave.setEnergyBrick(json.getInt("brick_last"));
                }else{
                    enklave.setShields(json.getInt("shield_full"));
                    enklave.setEnergyBrick(json.getInt("brick_last"));
                }
                enklave.setEnergyBrickfull(json.getInt("brick_full"));
                enklave.setEnergyfullshield(json.getInt("shield_full"));
                manager.getAssertEnklaveScreen().setIsupdate(true);
                Gdx.app.log("information enklave ", "succes  " + json);
            }else{
                Gdx.app.log("eroare"+httpResponse.getStatus().getStatusCode(),"meassajul :"+httpResponse.getResultAsString());
                new GetEnklaveDetails().makeRequest(ListEnklaves.getInstance().get(idEnklave).id, manager);
            }
        }

        @Override
        public void failed(Throwable t) {
            Gdx.app.log("information error failed"," "+ t);
            new GetEnklaveDetails().makeRequest(ListEnklaves.getInstance().get(idEnklave).id, manager);
        }

        @Override
        public void cancelled() {
            Gdx.app.log("information error cancelled","cancel");
        }
    });
}
 

开发者ID:TudorRosca,
项目名称:enklave,
代码行数:61,
代码来源:GetEnklaveDetails.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)