Package net.sourceforge.queried

Examples of net.sourceforge.queried.ServerInfo


  public @Override ServerQueryInformation queryServer(InetSocketAddress destination) {
    ServerQueryInformation query = new ServerQueryInformation();
    String ipStr = destination.getAddress().getHostAddress();
    int port = destination.getPort()+1; // UT2004 uses game port + 1 for server query
    long started = System.currentTimeMillis();
    ServerInfo serverInfo = QueriEd.serverQuery("UT2004",ipStr,port);
    query.ping = (int)(System.currentTimeMillis() - started);
    String serverName = null;
    if(serverInfo != null) {
      serverName = serverInfo.getName();
      query.mapName = serverInfo.getMap();
      int realport = Integer.parseInt(serverInfo.getPort());
      if(realport != destination.getPort())
        System.err.println("ERROR: real port from query: " + realport + "  is not the same as current destination port: " + destination.getPort());
      query.setPlayerCount(serverInfo.getPlayerCount());
      query.setMaxPlayerCount(serverInfo.getMaxPlayers());
      System.out.println("Queried server: " + serverName);
    } else
      System.err.println("Unable to query server.");
    query.serverName = serverName;
    return query;
View Full Code Here


  public @Override ServerQueryInformation queryServer(InetSocketAddress destination) {
    ServerQueryInformation query = new ServerQueryInformation();
    String ipStr = destination.getAddress().getHostAddress();
    int port = destination.getPort()+1; // AA uses gameport + 1 for query
    long started = System.currentTimeMillis();
    ServerInfo serverInfo = QueriEd.serverQuery("AA",ipStr,port);
    query.ping = (int)(System.currentTimeMillis() - started);
    //String queryResult = Util.getInfo(localPort, ipStr, port, infoType, queryType, gameType);
    String serverName = null;
    if(serverInfo != null) {
      serverName = serverInfo.getName();
      query.mapName = serverInfo.getMap();
      query.setPlayerCount(serverInfo.getPlayerCount());
      query.setMaxPlayerCount(serverInfo.getMaxPlayers());
      System.out.println("Queried server: " + serverName);
    } else {
      query.ping = -1;
      System.err.println("Unable to query server.");
    }
View Full Code Here

    ServerQueryInformation query = new ServerQueryInformation();
    String ipStr = destination.getAddress().getHostAddress();
    //int port = currentDestination.getPort()+1; // AA uses gameport + 1 for query
    int port = 23000; // BFV always uses the same port ?
    long started = System.currentTimeMillis();
    ServerInfo serverInfo = QueriEd.serverQuery("BFV",ipStr,port);
    query.ping = (int)(System.currentTimeMillis() - started);
    String serverName = null;
    if(serverInfo != null) {
      serverName = serverInfo.getName();
      int realport = Integer.parseInt(serverInfo.getPort());
      if(realport != destination.getPort())
        System.err.println("ERROR: real port from query: " + realport + "  is not the same as current destination port: " + destination.getPort());
      query.setPlayerCount(serverInfo.getPlayerCount());
      query.setMaxPlayerCount(serverInfo.getMaxPlayers());
      System.out.println("Queried server: " + serverName);
      query.mapName = serverInfo.getMap();
    } else
      System.err.println("Unable to query server.");
    query.serverName = serverName;
    return query;
  }
View Full Code Here

    ServerQueryInformation query = new ServerQueryInformation();
    String ipStr = destination.getAddress().getHostAddress();
    //int port = currentDestination.getPort()+1; // AA uses gameport + 1 for query
    int port = 29900; // BF2 always uses the same port ?
    long started = System.currentTimeMillis();
    ServerInfo serverInfo = QueriEd.serverQuery("BF2",ipStr,port);
    query.ping = (int)(System.currentTimeMillis() - started);
    String serverName = null;
    if(serverInfo != null) {
      serverName = serverInfo.getName();
      int realport = Integer.parseInt(serverInfo.getPort());
      if(realport != destination.getPort())
        System.err.println("ERROR: real port from query: " + realport + "  is not the same as current destination port: " + destination.getPort());
      query.setPlayerCount(serverInfo.getPlayerCount());
      query.setMaxPlayerCount(serverInfo.getMaxPlayers());
      System.out.println("Queried server: " + serverName);
    } else
      System.err.println("Unable to query server.");
    query.serverName = serverName;
    return query;
View Full Code Here

    ServerQueryInformation query = new ServerQueryInformation();
    String ipStr = destination.getAddress().getHostAddress();
    //int port = currentDestination.getPort()+1; // AA uses gameport + 1 for query
    int port = 23000; // BF2 always uses the same port ?
    long started = System.currentTimeMillis();
    ServerInfo serverInfo = QueriEd.serverQuery("BF",ipStr,port);
    query.ping = (int)(System.currentTimeMillis() - started);
    String serverName = null;
    if(serverInfo != null) {
      serverName = serverInfo.getName();
      int realport = Integer.parseInt(serverInfo.getPort());
      if(realport != destination.getPort())
        System.err.println("ERROR: real port from query: " + realport + "  is not the same as current destination port: " + destination.getPort());
      query.setPlayerCount(serverInfo.getPlayerCount());
      query.setMaxPlayerCount(serverInfo.getMaxPlayers());
      System.out.println("Queried server: " + serverName);
    } else
      System.err.println("Unable to query server.");
    query.serverName = serverName;
    return query;
View Full Code Here

    ServerQueryInformation query = new ServerQueryInformation();
   
    String ipStr = destination.getAddress().getHostAddress();
    int port = destination.getPort(); // Quake3 uses same port for query and game
    long started = System.currentTimeMillis();
    ServerInfo serverInfo = QueriEd.serverQuery("Q3",ipStr,port);
    query.ping = (int)(System.currentTimeMillis() - started);
    //String queryResult = Util.getInfo(localPort, ipStr, port, infoType, queryType, gameType);
    String serverName = null;
    if(serverInfo != null) {
      serverName = serverInfo.getName();
      System.out.println("Queried server: " + serverName);
      query.mapName = serverInfo.getMap();
      query.setPlayerCount(serverInfo.getPlayerCount());
      query.setMaxPlayerCount(serverInfo.getMaxPlayers());
    } else
      System.err.println("Unable to query server.");
    if(serverName == null) return null;
    query.serverName = serverName.replaceAll("\\^\\d","");
    return query;
View Full Code Here

   
    int infoType = QueriEd.INFO_DETAILS;
    int queryType = QueriEd.QUERY_GAMESPY2;
    int gameType = QueriEd.GAME_BF2;
        String queryResult = Util.getInfo(localPort, ipStr, port, infoType, queryType, gameType);
        ServerInfo serverInfo = null;
        if(queryResult != null && queryResult.length() > 0) {
            serverInfo = new ServerInfo();
            serverInfo.setGame(Util.getPartGS2(queryResult, "gamename"));
            serverInfo.setGameVersion(Util.getPartGS2(queryResult, "gamever"));
            serverInfo.setIp(ipStr);
            serverInfo.setPort(Util.getPartGS2(queryResult, "hostport"));
            serverInfo.setName(Util.getPartGS2(queryResult, "hostname"));
            serverInfo.setMap(Util.getPartGS2(queryResult, "mapname"));
            serverInfo.setPlayerCount(Util.getPartGS2(queryResult, "numplayers"));
            serverInfo.setMaxPlayers(Util.getPartGS2(queryResult, "maxplayers"));
           
            String gametype = Util.getPartGS2(queryResult,"gametype");
            String gamevariant = Util.getPartGS2(queryResult,"gamevariant");
           
            System.out.println("QueryResult: " + queryResult + "\n\n");
            System.out.println("Server: " + ipStr + ": " + serverInfo.getName());
            System.out.println("gametype: " + gametype + " - gamevariant: " + gamevariant);
        }
  }
View Full Code Here

        }
  }
    protected static void check(String gameType, String ip, int port) {
        System.out.println("ServerInfo ["+ gameType +"]:");

        ServerInfo serverInfo = QueriEd.serverQuery(gameType, ip, port);
        if(serverInfo == null) {
            System.out.println("ServerInfo == null");
        } else {
            System.out.println(serverInfo.getName() +" :: IP: "+ serverInfo.getIp()
                +":"+ serverInfo.getPort() +" :: "+ serverInfo.getGame() +" :: Map: "+ serverInfo.getMap()
                +" :: Players: "+ serverInfo.getPlayerCount() +"/"+ serverInfo.getMaxPlayers());
        }
        

        System.out.println("PlayerInfo:");
View Full Code Here

    if (queryResult == null || queryResult.length() < 1) {
      return null;
    }
    // queryResult = queryResult.substring(queryResult.indexOf("\\"));
    queryResult = queryResult.replaceAll("\\^([0-9a-wyzA-WYZ]|x[0-9a-fA-F]{6})", "");
    ServerInfo serverInfo = null;
    if (queryResult != null && queryResult.length() > 0) {
      serverInfo = new ServerInfo();
      String[] plyrs = queryResult.split("�>");

      serverInfo.setGame(Util.getPartGS2(queryResult, "si_gameType"));
      serverInfo.setIp(ipStr);
      serverInfo.setPort(port + "");
      serverInfo.setName(Util.getPartGS2(queryResult, "si_name"));
      serverInfo.setPlayerCount(plyrs.length - 1 + "");
      serverInfo.setMaxPlayers(Util.getPartGS2(queryResult, "si_maxPlayers"));
      serverInfo.setMap(Util.getPartGS2(queryResult, "si_map"));
      serverInfo.setFullResponse(queryResult);
    }

    return serverInfo;
  }
View Full Code Here

      return null;
    } else if (buf[0] != buf[1] || buf[1] != buf[2] || buf[2] != buf[3] || buf[4] != 'I') {
      return null;
    }

    ServerInfo serverInfo = new ServerInfo();

    InetAddress inettst;
    try {
      inettst = InetAddress.getByName(ipStr);
      serverInfo.setIp(inettst.getHostAddress());
    } catch (UnknownHostException e) {
      serverInfo.setIp(ipStr);
    }

    serverInfo.setPort(port + "");

    int off = 6;

    StringBuffer netName = new StringBuffer(20);
    while (buf[off] != 0) {
      netName.append((char) (buf[off++] & 255));
    }
    serverInfo.setName(netName.toString());

    off++;

    StringBuffer mapName = new StringBuffer(20);
    while (buf[off] != 0) {
      mapName.append((char) (buf[off++] & 255));
    }
    serverInfo.setMap(mapName.toString());

    off++;

    // skip game directory
    while (buf[off] != 0) {
      off++;
    }

    off++;

    StringBuffer gameDesc = new StringBuffer(20);
    while (buf[off] != 0) {
      gameDesc.append((char) (buf[off++] & 255));
    }
    serverInfo.setGame(gameDesc.toString());

    off++;

    // skip app id
    off++;

    off++;

    int playerCount = buf[off] & 255;
    serverInfo.setPlayerCount(playerCount + "");

    off++;

    int maxPlayerCount = buf[off] & 255;
    serverInfo.setMaxPlayers(maxPlayerCount + "");
    serverInfo.setFullResponse(new String(buf));

    return serverInfo;
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.queried.ServerInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.