Esempio n. 1
0
 public static LauncherProfiles load() throws IOException {
   System.out.println("Loading Minecraft profiles from " + DevLauncher.workingDirectory);
   try (FileReader reader = new FileReader(getFile())) {
     LauncherProfiles profiles = new LauncherProfiles();
     JsonObject e = new JsonParser().parse(reader).getAsJsonObject();
     for (Map.Entry<String, JsonElement> entry : e.entrySet()) {
       if (entry.getKey().equals("clientToken")) {
         profiles.clientToken = entry.getValue().getAsString();
       } else if (entry.getKey().equals("authenticationDatabase")) {
         JsonObject o = entry.getValue().getAsJsonObject();
         for (Map.Entry<String, JsonElement> entry1 : o.entrySet()) {
           profiles.authenticationDatabase.profiles.put(
               UUIDTypeAdapter.fromString(entry1.getKey()),
               GSON.fromJson(entry1.getValue(), OnlineProfile.class));
         }
       } else {
         profiles.everythingElse.add(entry.getKey(), entry.getValue());
       }
     }
     INSTANCE = profiles;
     return INSTANCE;
   } finally {
     if (INSTANCE == null) {
       INSTANCE = new LauncherProfiles();
     }
     INSTANCE.markLoaded();
   }
 }
    @Override
    // 1.data 통신
    public ArrayList<String> call() throws Exception {
      JSONResultString result = null;
      ArrayList<String> arrayList1 = new ArrayList<String>();
      try {

        HttpRequest request = post("http://192.168.0.5:8088/bitin/api/class/start-attd ");

        // reiquest 설정
        request.connectTimeout(2000).readTimeout(2000);
        // JSON  포맷으로 보내기  => POST 방식
        request.acceptCharset("UTF-8");
        request.acceptJson();
        request.accept(HttpRequest.CONTENT_TYPE_JSON);
        request.contentType("application/json", "UTF-8");

        // 데이터 세팅
        JSONObject params1 = new JSONObject();
        params1.put("classNo", classNo);
        params1.put("startTime", endTime);
        params1.put("timer", count_timer);

        Log.d("JoinData-->", params1.toString());
        request.send(params1.toString());

        // 3. 요청
        int responseCode = request.code();
        if (HttpURLConnection.HTTP_OK != responseCode) {
          Log.e("HTTP fail-->", "Http Response Fail:" + responseCode);
          return null;
        } else {
          Log.e("HTTPRequest-->", "정상");
        }

        // 4. JSON 파싱
        Reader reader = request.bufferedReader();
        // Log.d("Reader",reader);
        result = GSON.fromJson(reader, JSONResultString.class);
        reader.close();

        // 5. 사용하기
        Log.d("---> ResponseResult-->", result.getResult()); // "success"? or "fail"?
        Log.d("--->Data-->", result.getData().toString());

        return result.getData();

      } catch (Exception e3) {
        e3.printStackTrace();
      }
      return result.getData();
    }