Esempio n. 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();
   }
 }
Esempio n. 2
0
 public static void pingDarkstarClients() {
   for (String userId : clientMap.keySet()) {
     Player p = clientMap.get(userId);
     if (p.getDarkstarClient().isConnected()) {
       sendSessionMsgToDarkstar(p.getDarkstarClient(), "ping");
     }
   }
 }
Esempio n. 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();
   }
 }
Esempio n. 4
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();
    }
  }