本文整理汇总了Java中com.badlogic.gdx.net.HttpRequestBuilder类的典型用法代码示例。如果您正苦于以下问题:Java HttpRequestBuilder类的具体用法?Java HttpRequestBuilder怎么用?Java HttpRequestBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HttpRequestBuilder类属于com.badlogic.gdx.net包,在下文中一共展示了HttpRequestBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: updateNetwork
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的package包/类
public void updateNetwork() {
isOnline = false;
Gdx.net.sendHttpRequest(new HttpRequestBuilder().newRequest().method(Net.HttpMethods.GET).url("http://checkip.amazonaws.com").build(), new Net.HttpResponseListener() {
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
try {
ip = new BufferedReader(new InputStreamReader(httpResponse.getResultAsStream())).readLine();
isOnline = true;
//client.connect(5000, "99.36.127.68", Networking.PORT);
//client.reconnect();
} catch (IOException e) {
Gdx.app.error("HTTP", e.toString());
}
}
@Override
public void failed(Throwable t) {
Gdx.app.log("Update Network", t.toString());
}
@Override
public void cancelled() {
}
});
}
开发者ID:justinmarentette11,项目名称:Tower-Defense-Galaxy,代码行数:25,代码来源:TDGalaxy.java
示例2: getTicket
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的package包/类
public static void getTicket(final WebSocketLocal webSocket){
final JSONObject[] finalResult = new JSONObject[1];
String accesToken = Gdx.app.getPreferences("informationLog").getString("accesstoken");
HttpRequestBuilder buider = new HttpRequestBuilder();
Net.HttpRequest request = buider.newRequest().url(api_url + d_login).method(Net.HttpMethods.POST).build();
request.setHeader("Authorization", "Bearer " + accesToken);
Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
String r = httpResponse.getResultAsString();
webSocket.connectWebSocket(new JSONObject(r));
Gdx.app.log("response", "ticket "+r);
}
@Override
public void failed(Throwable t) {
webSocket.connectWebSocket(new JSONObject());
}
@Override
public void cancelled() {
webSocket.connectWebSocket(new JSONObject());
}
});
}
开发者ID:TudorRosca,项目名称:enklave,代码行数:26,代码来源:RequestTokenSocket.java
示例3: makeRequestEnklave
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的package包/类
public void makeRequestEnklave(){
Preferences pref = Gdx.app.getPreferences("informationLog");
String acces = pref.getString("accesstoken");
HttpRequestBuilder builder = new HttpRequestBuilder();
Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.GET).url(url + enkNearby).build();
request.setHeader("Authorization", "Bearer " + acces);
Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
String response = httpResponse.getResultAsString();
JSONArray jsonArray = new JSONArray(response);
ListEnklaves.getInstance().setListEnklave(jsonArray);
Gdx.app.log("response enklave : " + httpResponse.getStatus().getStatusCode(), " message " +response);
}
@Override
public void failed(Throwable t) {
Gdx.app.log("response : " + t.getMessage(), "fdg " + t.getLocalizedMessage());
}
@Override
public void cancelled() {
Gdx.app.log("response ","cancelled");
}
});
}
开发者ID:TudorRosca,项目名称:enklave,代码行数:27,代码来源:NearbyEnklave.java
示例4: sendMessage
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的package包/类
public void sendMessage(String message){
final Preferences pref = Gdx.app.getPreferences("informationLog");
String acces = pref.getString("accesstoken");
JSONObject json = new JSONObject();
json.accumulate("txt",message);
HttpRequestBuilder builder = new HttpRequestBuilder();
Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + join).build();
request.setHeader("Authorization", "Bearer " + acces);
request.setHeader("Content-type", "application/json");
request.setContent(json.toString());
Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
//Gdx.app.log("response :"+httpResponse.getStatus().getStatusCode(),"message "+httpResponse.getResultAsString());
}
@Override
public void failed(Throwable t) {
//Gdx.app.log("response :","failed "+t);
}
@Override
public void cancelled() {
//Gdx.app.log("response :","cancel ");
}
});
}
开发者ID:TudorRosca,项目名称:enklave,代码行数:28,代码来源:SendFaction.java
示例5: sendMessage
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的package包/类
public void sendMessage(String message){
final Preferences pref = Gdx.app.getPreferences("informationLog");
String acces = pref.getString("accesstoken");
JSONObject json = new JSONObject();
json.accumulate("txt",message);
HttpRequestBuilder builder = new HttpRequestBuilder();
Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + join).build();
request.setHeader("Authorization", "Bearer " + acces);
request.setHeader("Content-type", "application/json");
request.setContent(json.toString());
Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
// Gdx.app.log("response :"+httpResponse.getStatus().getStatusCode(),"message "+httpResponse.getResultAsString());
}
@Override
public void failed(Throwable t) {
//Gdx.app.log("response :","failed "+t);
}
@Override
public void cancelled() {
//Gdx.app.log("response :","cancel ");
}
});
}
开发者ID:TudorRosca,项目名称:enklave,代码行数:28,代码来源:SendLocation.java
示例6: makeRequest
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的package包/类
public void makeRequest(int id){
final Preferences pref = Gdx.app.getPreferences("informationLog");
String acces = pref.getString("accesstoken");
JSONObject json = new JSONObject();
json.accumulate("faction_id",id);
HttpRequestBuilder builder = new HttpRequestBuilder();
Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + join).build();
request.setHeader("Authorization", "Bearer " + acces);
request.setHeader("Content-type", "application/json");
request.setContent(json.toString());
Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
//Gdx.app.log("response :","message "+httpResponse.getResultAsString());
}
@Override
public void failed(Throwable t) {
//Gdx.app.log("response :","failed ");
}
@Override
public void cancelled() {
//Gdx.app.log("response :","cancel ");
}
});
}
开发者ID:TudorRosca,项目名称:enklave,代码行数:28,代码来源:JoinFaction.java
示例7: makeRequest
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的package包/类
public void makeRequest(int id, final ScreenCombat screenCombat){
final Preferences pref = Gdx.app.getPreferences("informationLog");
final String acces = pref.getString("accesstoken");
JSONObject parameters = new JSONObject();
parameters.accumulate("enklave_combat_id",id);
HttpRequestBuilder builder = new HttpRequestBuilder();
Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + prof).build();
request.setHeader("Authorization", "Bearer " + acces);
request.setHeader("Content-type", "application/json");
request.setContent(parameters.toString());
Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
screenCombat.showCover();
Gdx.app.log("raspuns hit Enklave cod :"+httpResponse.getStatus().getStatusCode()," message : "+httpResponse.getResultAsString());
}
@Override
public void failed(Throwable t) {
}
@Override
public void cancelled() {
}
});
}
开发者ID:TudorRosca,项目名称:enklave,代码行数:29,代码来源:HitEnklave.java
示例8: makeRequest
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的package包/类
public void makeRequest(int id, final ScreenCombat screenCombat){
final Preferences pref = Gdx.app.getPreferences("informationLog");
final String acces = pref.getString("accesstoken");
JSONObject jsonObject = new JSONObject();
jsonObject.accumulate("enklave_id", id);
HttpRequestBuilder builder = new HttpRequestBuilder();
Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + prof).build();
request.setHeader("Authorization", "Bearer " + acces);
request.setHeader("Content-type", "application/json");
request.setContent(jsonObject.toString());
Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
String res = httpResponse.getResultAsString();
Gdx.app.log("raspuns start code "+httpResponse.getStatus().getStatusCode(),"rasp mess: "+res);
if(httpResponse.getStatus().getStatusCode()<300){
JSONObject j = new JSONObject(res);
informationProfile.getDateUserGame().setEnklaveCombatId(j.getInt("enklave_combatant_id"));
InformationEnklave.getInstance().setCombatId(j.getInt("enklave_combat_id"));
informationProfile.getDateUserGame().setInCombat(true);
}else{
JSONObject json = new JSONObject(res);
if(json.getString("detail").contentEquals("You already joined this combat once"))
InformationProfile.getInstance().getDateUserGame().setEnklaveCombatId(-1);
informationProfile.getDateUserGame().setInCombat(true);
screenCombat.dialogExit(json.getString("detail").substring(0,20)+"\n"+json.getString("detail").substring(21));
}
}
@Override
public void failed(Throwable t) {
Gdx.app.log("error parse data : ","err: "+t);
}
@Override
public void cancelled() {
}
});
}
开发者ID:TudorRosca,项目名称:enklave,代码行数:41,代码来源:StartCombat.java
示例9: makeRequest
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的package包/类
public void makeRequest(int id){
final Preferences pref = Gdx.app.getPreferences("informationLog");
final String acces = pref.getString("accesstoken");
JSONObject parameters = new JSONObject();
parameters.accumulate("enklave_id",id);
HttpRequestBuilder builder = new HttpRequestBuilder();
Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + prof).build();
request.setHeader("Authorization", "Bearer " + acces);
request.setHeader("Content-type", "application/json");
request.setContent(parameters.toString());
Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
Gdx.app.log("raspuns unsubscribe cod :"," message : "+httpResponse.getResultAsString());
}
@Override
public void failed(Throwable t) {
}
@Override
public void cancelled() {
}
});
}
开发者ID:TudorRosca,项目名称:enklave,代码行数:28,代码来源:UnsubscribeCombat.java
示例10: makeRequest
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的package包/类
public void makeRequest(int id, final ScreenCombat screenCombat){
final Preferences pref = Gdx.app.getPreferences("informationLog");
final String acces = pref.getString("accesstoken");
JSONObject parameters = new JSONObject();
parameters.accumulate("enklave_combatant_id",id);
HttpRequestBuilder builder = new HttpRequestBuilder();
Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + prof).build();
request.setHeader("Authorization", "Bearer " + acces);
request.setHeader("Content-type", "application/json");
request.setContent(parameters.toString());
Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
screenCombat.showCover();
Gdx.app.log("raspuns hit user cod :"+httpResponse.getStatus().getStatusCode()," message : "+httpResponse.getResultAsString());
}
@Override
public void failed(Throwable t) {
}
@Override
public void cancelled() {
}
});
}
开发者ID:TudorRosca,项目名称:enklave,代码行数:29,代码来源:HitUser.java
示例11: makeRequest
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的package包/类
public void makeRequest(final int id){
final Preferences pref = Gdx.app.getPreferences("informationLog");
final String acces = pref.getString("accesstoken");
JSONObject parameters = new JSONObject();
parameters.accumulate("enklave_id",id);
HttpRequestBuilder builder = new HttpRequestBuilder();
Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + prof).build();
request.setHeader("Authorization", "Bearer " + acces);
request.setHeader("Content-type", "application/json");
request.setContent(parameters.toString());
Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
// Gdx.app.log("response "+httpResponse.getStatus().getStatusCode()," subscribe "+httpResponse.getResultAsString());
if(httpResponse.getStatus().getStatusCode()<300){
new CheckStatus().makeRequest(id);
}else{
}
}
@Override
public void failed(Throwable t) {
}
@Override
public void cancelled() {
}
});
}
开发者ID:TudorRosca,项目名称:enklave,代码行数:33,代码来源:SubscribeCombat.java
示例12: addScore
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的package包/类
public void addScore(AddScoreListener listener, int score, String name) {
HttpRequestBuilder requestBuilder = new HttpRequestBuilder();
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("name", name);
parameters.put("score", "" + score);
Net.HttpRequest httpRequest = requestBuilder.newRequest()
.method(Net.HttpMethods.POST)
.formEncodedContent(parameters)
.url("https://www.fluffybalance.nl/api/1.0/score")
.build();
Gdx.net.sendHttpRequest(httpRequest, new AddScoreResponseListener(listener));
}
开发者ID:tgobbens,项目名称:fluffybalance,代码行数:14,代码来源:LeaderBoardController.java
示例13: GET
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的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
示例14: sendRequest
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的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
示例15: makeRequest
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的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
示例16: makeRequestProfile
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的package包/类
public void makeRequestProfile(){
final Preferences pref = Gdx.app.getPreferences("informationLog");
final String acces = pref.getString("accesstoken");
// Gdx.app.log("response "," access token "+acces);
HttpRequestBuilder builder = new HttpRequestBuilder();
Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.GET).url(url + prof).build();
request.setHeader("Authorization", "Bearer " + acces);
Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
if(httpResponse.getStatus().getStatusCode()<300) {
JSONObject json = new JSONObject(httpResponse.getResultAsString());
profile.getDateUser().setId(json.getInt("id"));
profile.getDateUser().setUserName(json.getString("username"));
profile.getDateUser().setFristName(json.getString("first_name"));
profile.getDateUser().setLastName(json.getString("last_name"));
profile.getDateUser().setEmail(json.getString("email"));
profile.getDateUser().setPhoneNumber(json.getString("phone_number"));
if (json.getString("faction") == "null") {
profile.getDateUserGame().setFaction(0);
} else {
profile.getDateUserGame().setFaction(json.getInt("faction"));
}
profile.getDateUserGame().setScrap(json.getInt("scrap"));
profile.getDateUserGame().setLevel(json.getInt("level"));
profile.getDateUserGame().setEnergyProgress(json.getJSONObject("energy_config").getInt("PLAYER_RECHARGE_PROGRESSION"));
profile.getDateUserGame().setEnergyLevel(json.getJSONObject("energy_config").getInt("PLAYER_ENERGY_PROGRESSION"));
profile.getDateUserGame().setEnergy(json.getInt("energy"));
profile.getDateUserGame().setExperienceLevel(json.getJSONObject("xp_for_level").getInt("PLAYER_XP_PROGRESSION"));
profile.getDateUserGame().setExperience(json.getInt("experience"));
profile.getDateUserGame().setDistanceWalked(json.getInt("distance_walked"));
// profile.getDateUserGame().setElectronics(json.getInt("electronics"));
profile.getDateBrick().setNumber(json.getInt("nr_bricks"));
profile.getDateBrick().setRateEnergy(json.getJSONObject("brick_config").getInt("CRAFT_BRICK_ENERGY_COST"));
profile.getDateBrick().setRateScrap(json.getJSONObject("brick_config").getInt("CRAFT_BRICK_SCRAP_COST"));
profile.getDateBrick().setRateTime(json.getJSONObject("brick_config").getInt("CRAFT_BRICK_TIME_COST"));
profile.getDateBrick().setUsageEnergy(json.getJSONObject("place_brick_config").getInt("PLACE_BRICK_ENERGY_COST"));
profile.getDateBrick().setUsageTime(json.getJSONObject("place_brick_config").getInt("PLACE_BRICK_TIME_COST"));
profile.getDateCell().setCellNumber(json.getInt("nr_cells"));
profile.getDateCell().setCellValue(json.getJSONObject("cell_configs").getInt("ENERGY_CELL_RECHARGE_VALUE"));
profile.getDateCell().setCellRateTime(json.getJSONObject("cell_configs").getInt("CRAFTING_TIME_CELL"));
profile.getDateCell().setCellRateScrap(json.getJSONObject("cell_configs").getInt("CONVERSION_RATE_CELL"));
profile.getDateCell().setCellRateEnergy(profile.getDateCell().getCellValue() * (json.getJSONObject("cell_configs").getInt("CELL_ENERGY_PERCENTAGE_COST") / 100) + profile.getDateCell().getCellValue());
profile.getDateCell().setCellUsageEnergy(json.getJSONObject("cell_configs").getInt("PLAYER_CELL_RELOAD_TIME"));
profile.getDateCell().setCellUsageTime(json.getJSONObject("cell_configs").getInt("PLAYER_ENERGY_CELL_USAGE_COST"));
Gdx.app.log("response profil " + "status : " + httpResponse.getStatus().getStatusCode(), acces + " message " + json.toString());
new Thread(new Runnable() {
@Override
public void run() {
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
new CombatUserCheck().makeRequest();
}
});
}
}).start();
}else{
if(httpResponse.getStatus().getStatusCode() == 401){
}
}
}
@Override
public void failed(Throwable t) {
Gdx.app.log("response : " + t.getMessage(), "fdg " + t.getLocalizedMessage());
new GetProfile().makeRequestProfile();
}
@Override
public void cancelled() {
}
});
}
开发者ID:TudorRosca,项目名称:enklave,代码行数:81,代码来源:GetProfile.java
示例17: makeRequestProfile
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的package包/类
public void makeRequestProfile() {
final Preferences pref = Gdx.app.getPreferences("informationLog");
final String acces = pref.getString("accesstoken");
Gdx.app.log("response ", " access token " + acces);
JSONObject jsonObject = new JSONObject();
jsonObject.accumulate("client_id", "EeTst6oR0udDrcKUScROksiDKiBPdUvp8leTWVVO");
jsonObject.accumulate("client_secret", "goGcpJ1QPiAoTTOQRIGya6cCau0TTNpcrpzKudHynfPvcmYHKuWh0IpH8vEB2ZHYVAt6qOKdNXQZkMP1yKUYYDXX5sEu8ACr9mthmgR9ytaDqoXindSbX568r45saSiN");
jsonObject.accumulate("grant_type", "refresh_token");
jsonObject.accumulate("username", pref.getString("username"));
jsonObject.accumulate("refresh_token", pref.getString("refreshToken"));
final String json = jsonObject.toString();
HttpRequestBuilder builder = new HttpRequestBuilder();
Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + prof).build();
request.setHeader("Content-type", "application/json");
request.setContent(json.toString());
Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
if(httpResponse.getStatus().getStatusCode()<300) {
JSONObject jsonObj = new JSONObject(httpResponse.getResultAsString());
pref.putString("accesstoken",jsonObj.getString("access_token"));
pref.putString("refreshToken",jsonObj.getString("refresh_token"));
pref.putLong("timeout", (System.currentTimeMillis() +((jsonObj.getLong("expires_in") - 1000) * 1000)));
pref.flush();
new GetProfile().makeRequestProfile();
}else{
System.exit(0);
}
}
@Override
public void failed(Throwable t) {
Gdx.app.log("response failed","error : "+t.getMessage()+" localizedMessage: "+t.getLocalizedMessage());
}
@Override
public void cancelled() {
Gdx.app.log("response cancelled","eror");
}
});
}
开发者ID:TudorRosca,项目名称:enklave,代码行数:42,代码来源:RefreshAccessToken.java
示例18: makeRequest
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的package包/类
public void makeRequest(final GameManager game, final QueueBuildCraft queue){
Preferences pref = Gdx.app.getPreferences("informationLog");
String acces = pref.getString("accesstoken");
HttpRequestBuilder builder = new HttpRequestBuilder();
Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + prof).build();
request.setHeader("Authorization", "Bearer " + acces);
updateprofile(-1);
queue.getElement();
final long startTime = System.currentTimeMillis();
try {
Thread.sleep((System.currentTimeMillis() > queue.dateStartLastAction) ? 0 : (queue.dateStartLastAction - System.currentTimeMillis()));
} catch (InterruptedException e) {
e.printStackTrace();
Gdx.app.log("intra brick ","error");
}
queue.dateStartLastAction = System.currentTimeMillis() + (informationProfile.getDateBrick().getRateTime()*1000);
Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
JSONObject json = new JSONObject(httpResponse.getResultAsString());
if(httpResponse.getStatus().getStatusCode()<300){
if(json.has("duration")) {
new Timer().schedule(new Timer.Task() {
@Override
public void run() {
informationProfile.getDateBrick().setNumber(informationProfile.getDateBrick().getNumber() + 1);
queueDisplay.labelfinishaction.setText("Brick");
queueDisplay.labelcurrentaction.setText("");
queueDisplay.labelnextaction.setText("");
game.screenCrafting.updateDisplay();
Gdx.app.log("number bricks", "ga " + informationProfile.getDateBrick().getNumber());
if(!queue.forcestopcrafting)
queue.startThread();
}
},informationProfile.getDateBrick().getRateTime());
}else {
Gdx.app.log("response error create bricks "+httpResponse.getStatus().getStatusCode()," "+json);
// game.screenCrafting.createDialog("Error create brick "+json);
updateprofile(1);
queue.clearQueue();
queueDisplay.labelfinishaction.setText("");
queueDisplay.labelcurrentaction.setText("brick error");
queueDisplay.labelnextaction.setText("");
}
}else{
// game.screenCrafting.createDialog("Error create brick " +json);
Gdx.app.log("response error create bricks "+httpResponse.getStatus().getStatusCode()," "+json);
updateprofile(1);
queue.clearQueue();
queueDisplay.labelfinishaction.setText("");
queueDisplay.labelcurrentaction.setText("brick error ");
queueDisplay.labelnextaction.setText("");
}
}
@Override
public void failed(Throwable t) {
Gdx.app.log("response create bricks","failed ");
}
@Override
public void cancelled() {
Gdx.app.log("response create bricks"," canceled");
}
});
new Timer().scheduleTask(new Timer.Task() {
@Override
public void run() {
// if(!queue.forcestopcrafting)
// queue.startThread();
}
},informationProfile.getDateBrick().getRateTime() + 0.5f);
}
开发者ID:TudorRosca,项目名称:enklave,代码行数:74,代码来源:CreateBricks.java
示例19: makeRequest
import com.badlogic.gdx.net.HttpRequestBuilder; //导入依赖的package包/类
public void makeRequest(final GameManager game, final QueueBuildCraft queue){
Preferences pref = Gdx.app.getPreferences("informationLog");
String acces = pref.getString("accesstoken");
HttpRequestBuilder builder = new HttpRequestBuilder();
Net.HttpRequest request = builder.newRequest().method(Net.HttpMethods.POST).url(url + prof).build();
request.setHeader("Authorization", "Bearer " + acces);
updateprofile(-1);
queue.getElement();
final long startTime = System.currentTimeMillis();
try {
Thread.sleep((System.currentTimeMillis() > queue.dateStartLastAction) ? 0 : (queue.dateStartLastAction - System.currentTimeMillis()));
} catch (InterruptedException e) {
e.printStackTrace();
}
queue.dateStartLastAction = System.currentTimeMillis() + (informationProfile.getDateCell().getCellRateTime() * 1000);
Gdx.net.sendHttpRequest(request, new Net.HttpResponseListener() {
@Override
public void handleHttpResponse(Net.HttpResponse httpResponse) {
JSONObject json = new JSONObject(httpResponse.getResultAsString());
if (httpResponse.getStatus().getStatusCode() < 300) {
if (json.has("duration")) {
new Timer().schedule(new Timer.Task() {
@Override
public void run() {
informationProfile.getDateCell().setCellNumber(informationProfile.getDateCell().getCellNumber() + 1);
queueDisplay.labelfinishaction.setText("Cell");
queueDisplay.labelcurrentaction.setText("");
queueDisplay.labelnextaction.setText("");
game.screenCrafting.updateDisplay();
Gdx.app.log("number cell", "ga " + informationProfile.getDateBrick().getNumber());
if(!queue.forcestopcrafting)
queue.startThread();
}
}, informationProfile.getDateCell().getCellRateTime());
} else {
Gdx.app.log("response error create cell " + httpResponse.getStatus().getStatusCode(), " " + json);
// game.screenCrafting.createDialog(json.getString("detail"));
updateprofile(1);
queue.clearQueue();
queueDisplay.labelfinishaction.setText("");
queueDisplay.labelcurrentaction.setText("cell error");
queueDisplay.labelnextaction.setText("");
}
} else {
Gdx.app.log("response error create cell " + httpResponse.getStatus().getStatusCode(), " " + json);
// game.screenCrafting.createDialog("Error create Cell!");
updateprofile(1);
queue.clearQueue();
queueDisplay.labelfinishaction.setText("");
queueDisplay.labelcurrentaction.setText("cell error");
|
请发表评论