|
|
@ -8,6 +8,7 @@ import app.entities.server.players.RCONPlayer; |
|
|
|
import com.fasterxml.jackson.annotation.JsonGetter; |
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
|
|
|
import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
|
|
|
import com.ibasco.agql.core.exceptions.ReadTimeoutException; |
|
|
|
import com.ibasco.agql.protocols.valve.source.query.SourceQueryClient; |
|
|
|
import com.ibasco.agql.protocols.valve.source.query.info.SourceQueryInfoResponse; |
|
|
|
import com.ibasco.agql.protocols.valve.source.query.players.SourceQueryPlayerResponse; |
|
|
@ -69,14 +70,18 @@ public class Stats { |
|
|
|
uniq.merge(key, value, (x,y) -> y); |
|
|
|
} |
|
|
|
|
|
|
|
public void RefreshServerA2SData(ApplicationContext context, String server_name){ |
|
|
|
public void RefreshServerA2SData(ApplicationContext context, String server_name) throws IOException { |
|
|
|
try (SourceQueryClient sourceQueryClient = context.getBean(SourceQueryClient.class)) { |
|
|
|
SourceQueryInfoResponse info = sourceQueryClient.getInfo(getServers().get(server_name).getInetAddress()).join(); |
|
|
|
getServers().get(server_name).UpdateStatusFromA2S(info); |
|
|
|
} catch (IOException err_info) { |
|
|
|
getServers().get(server_name).SetDownStatus(); |
|
|
|
return; |
|
|
|
} |
|
|
|
sourceQueryClient.getInfo(getServers().get(server_name).getInetAddress()).whenComplete((info, error) -> { |
|
|
|
sourceQueryClient.getExecutor().shutdown(); |
|
|
|
if (error != null) { |
|
|
|
getServers().get(server_name).SetDownStatus(); |
|
|
|
return; |
|
|
|
} |
|
|
|
getServers().get(server_name).UpdateStatusFromA2S(info); |
|
|
|
}).join(); |
|
|
|
} catch (CompletionException err) {} |
|
|
|
|
|
|
|
if (!getServers().get(server_name).isStatus() || getServers().get(server_name).getPlayer_count() < 1) { |
|
|
|
return; |
|
|
|
} |
|
|
@ -84,10 +89,11 @@ public class Stats { |
|
|
|
//If player count > 0 make base player request
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
try (SourceQueryClient sourceQueryClient = context.getBean(SourceQueryClient.class)) { |
|
|
|
SourceQueryPlayerResponse players = sourceQueryClient.getPlayers(getServers().get(server_name).getInetAddress()).join(); |
|
|
|
getServers().get(server_name).UpdatePlayersFromA2S(players); |
|
|
|
} catch (IOException err_players) { |
|
|
|
return; |
|
|
|
sourceQueryClient.getPlayers(getServers().get(server_name).getInetAddress()).whenComplete((players, error) -> { |
|
|
|
sourceQueryClient.getExecutor().shutdown(); |
|
|
|
if (error != null) return; |
|
|
|
getServers().get(server_name).UpdatePlayersFromA2S(players); |
|
|
|
}).join(); |
|
|
|
} |
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
//Extend current players of rcon result
|
|
|
|