Example #1
0
 private static void loadLoginSequence(String userId) {
   URLConnection urlConnection;
   CharSequence charSequence = "loginSeq=";
   String tempString = "";
   BufferedReader in;
   try {
     if (PlayersController.getPlayerClient(userId).isConnected()) {
       URL url =
           new URL("http://tcg.dyndns.info:8081/mcslcard/data/saveLogin.jsp?userId=" + userId);
       urlConnection = url.openConnection();
       in = new BufferedReader(new InputStreamReader((InputStream) urlConnection.getContent()));
       while ((tempString = in.readLine()) != null) {
         if (tempString.contains(charSequence)) {
           tempString = tempString.substring(charSequence.length(), tempString.length());
         }
         JSONObject jsonObjNest = new JSONObject();
         jsonObjNest.put("loginSeq", tempString);
         JSONObject jsonObj = new JSONObject();
         jsonObj.put("cmd", "SET_LOGIN_SEQ");
         jsonObj.put("parameters", jsonObjNest);
         jsonObj.put("scene", "ALL_SCENE");
         sendSessionMsgToDarkstar(PlayersController.getPlayerClient(userId), jsonObj.toString());
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Example #2
0
  public static void getPlayerInitData(String userId) {
    URLConnection urlConnection;
    try {
      if (PlayersController.getPlayerClient(userId).isConnected()) {
        URL url =
            new URL(
                "http://tcg.dyndns.info:8081/mcslcard/data/initPlayerData.jsp?userId=" + userId);

        urlConnection = url.openConnection();
        JSONObject jsonObjNest =
            new XMLParser().parseStream((InputStream) urlConnection.getContent());
        JSONObject jsonObj = new JSONObject();
        jsonObj.put("cmd", "INIT_PLAYER_DATA");
        jsonObj.put("parameters", jsonObjNest);
        jsonObj.put("scene", "ALL_SCENE");
        sendSessionMsgToDarkstar(PlayersController.getPlayerClient(userId), jsonObj.toString());
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Example #3
0
 public static void createRoom(String userId, String roomName, String roomPassword) {
   try {
     JSONObject jsonObj = new JSONObject();
     jsonObj.append("cmd", "CREATE_ROOM");
     jsonObj.append("scene", "LOBBY");
     JSONObject jsonObjNest = new JSONObject();
     jsonObjNest.append("roomName", roomName);
     jsonObjNest.append("roomPwd", roomPassword);
     jsonObj.append("parameters", jsonObjNest);
     PlayersController.sendSessionMsgToDarkstar(getPlayerClient(userId), jsonObj.toString());
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Example #4
0
  private static boolean loginDarkstar(String userId, String password) {
    String host = "tcg.dyndns.info";
    String port = "842";
    SimpleClient playerClient = null;
    try {
      Properties connectProps = new Properties();
      connectProps.put("host", host);
      connectProps.put("port", port);
      createPlayerClient(userId, password, false);
      playerClient = getPlayerClient(userId);
      playerClient.login(connectProps);
      Thread.sleep(5000);

      if (!playerClient.isConnected()) {
        PlayersController.removePlayer(userId);
      }

    } catch (Exception exception) {
      exception.printStackTrace();
      System.err.println(exception.getMessage());
    }
    return playerClient != null && playerClient.isConnected();
  }