Add version info in status tracking since we may end up having multiple versions out across the network for testing

This commit is contained in:
NovaFox161
2020-08-03 04:14:48 -05:00
parent 402c43fd70
commit 0e794f975f
3 changed files with 57 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
package org.dreamexposure.discal.core.object.network.discal;
import org.dreamexposure.discal.core.utils.GlobalConst;
import org.json.JSONObject;
import java.text.SimpleDateFormat;
@@ -16,6 +17,9 @@ import java.util.Date;
public class ConnectedClient {
private int clientIndex;
private String version;
private String d4jVersion;
private int connectedServers;
private long lastKeepAlive;
private String uptime;
@@ -29,6 +33,9 @@ public class ConnectedClient {
ConnectedClient() {
this.clientIndex = -1;
this.version = GlobalConst.version;
this.d4jVersion = GlobalConst.d4jVersion;
this.connectedServers = 0;
this.lastKeepAlive = System.currentTimeMillis();
@@ -39,6 +46,9 @@ public class ConnectedClient {
public ConnectedClient(final int _clientIndex) {
this.clientIndex = _clientIndex;
this.version = GlobalConst.version;
this.d4jVersion = GlobalConst.d4jVersion;
this.connectedServers = 0;
this.lastKeepAlive = System.currentTimeMillis();
@@ -51,6 +61,14 @@ public class ConnectedClient {
return this.clientIndex;
}
public String getVersion() {
return this.version;
}
public String getD4JVersion() {
return this.d4jVersion;
}
public int getConnectedServers() {
return this.connectedServers;
}
@@ -90,6 +108,14 @@ public class ConnectedClient {
this.clientIndex = clientIndex;
}
public void setVersion(final String version) {
this.version = version;
}
public void setD4JVersion(final String d4jVersion) {
this.d4jVersion = d4jVersion;
}
public void setConnectedServers(final int _connectedServers) {
this.connectedServers = _connectedServers;
}
@@ -122,6 +148,8 @@ public class ConnectedClient {
final JSONObject json = new JSONObject();
json.put("index", this.clientIndex);
json.put("version", this.version);
json.put("d4j_version", this.d4jVersion);
json.put("guilds", this.connectedServers);
json.put("keep_alive", this.lastKeepAlive);
json.put("uptime", this.uptime);
@@ -132,6 +160,8 @@ public class ConnectedClient {
public ConnectedClient fromJson(final JSONObject json) {
this.clientIndex = json.getInt("index");
this.version = json.getString("version");
this.d4jVersion = json.getString("d4j_version");
this.connectedServers = json.getInt("guilds");
this.lastKeepAlive = json.getLong("keep_alive");
this.uptime = json.getString("uptime");

View File

@@ -4,6 +4,7 @@ import org.dreamexposure.discal.core.database.DatabaseManager;
import org.dreamexposure.discal.core.logger.LogFeed;
import org.dreamexposure.discal.core.logger.object.LogObject;
import org.dreamexposure.discal.core.object.BotSettings;
import org.dreamexposure.discal.core.utils.GlobalConst;
import org.joda.time.Interval;
import org.joda.time.Period;
import org.json.JSONArray;
@@ -89,6 +90,14 @@ public class NetworkInfo {
}
}
public String getVersion() {
return GlobalConst.version;
}
public String getD4JVersion() {
return GlobalConst.d4jVersion;
}
public int getTotalGuildCount() {
int count = 0;
for (final ConnectedClient cc : this.clients) {
@@ -150,6 +159,8 @@ public class NetworkInfo {
public JSONObject toJson() {
final JSONObject json = new JSONObject();
json.put("api_version", this.getVersion());
json.put("d4j_version", this.getD4JVersion());
json.put("api_uptime", this.getUptimeLatest());
json.put("api_pid", this.getPid());
json.put("announcements", this.getAnnouncementCount());

View File

@@ -231,6 +231,14 @@
<!--Start Server Status-->
<h2 class="text-center text-discal-blue">Server</h2>
<p class="text-left text-discord-full-white"
th:text="'Version: ' + ${status.version}">
</p>
<p class="text-left text-discord-full-white"
th:text="'Discord4J Version: ' + ${status.d4JVersion}">
</p>
<p class="text-left text-discord-full-white"
th:text="'Connected Clients: ' + ${status.clientCount}">
</p>
@@ -295,6 +303,14 @@
<h3 class="text-left text-discord-full-white"
th:text="'Client Index: ' + ${client.clientIndex}"></h3>
<p class="text-left text-discord-full-white"
th:text="'Version: ' + ${client.version}">
</p>
<p class="text-left text-discord-full-white"
th:text="'Discord4J Version: ' + ${client.d4JVersion}">
</p>
<p class="text-left text-discord-full-white"
th:text="'Guilds: ' + ${client.connectedServers}">
</p>