aboutsummaryrefslogtreecommitdiff
path: root/lib/MasterWebInterface/Handler/Json/Motd.pm
diff options
context:
space:
mode:
authorDarkelarious <darkelarious@333networks.com>2022-08-07 17:58:59 +0200
committerDarkelarious <darkelarious@333networks.com>2022-08-07 17:58:59 +0200
commit1ca9cdc52f3b63c8bf5e4550bbb922608beb437f (patch)
tree90802c7f7800c1b9d2d5d22f0e6b41b373ec39b9 /lib/MasterWebInterface/Handler/Json/Motd.pm
parente9b4cd5fc79ca2d044eba4fed8bf62b138f44249 (diff)
downloadWebInterface-Perl-1ca9cdc52f3b63c8bf5e4550bbb922608beb437f.tar.gz
WebInterface-Perl-1ca9cdc52f3b63c8bf5e4550bbb922608beb437f.zip
fixes in Json API
Diffstat (limited to 'lib/MasterWebInterface/Handler/Json/Motd.pm')
-rwxr-xr-xlib/MasterWebInterface/Handler/Json/Motd.pm20
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/MasterWebInterface/Handler/Json/Motd.pm b/lib/MasterWebInterface/Handler/Json/Motd.pm
index 869ae5f..15c57a6 100755
--- a/lib/MasterWebInterface/Handler/Json/Motd.pm
+++ b/lib/MasterWebInterface/Handler/Json/Motd.pm
@@ -30,22 +30,26 @@ sub json_motd
# get numServers
my ($l,$x,$s) = $self->dbServerListGet(
gamename => $gamename,
- results => 100,
+ updated => $self->{window_time},
+ limit => 9999,
+ sort => "numplayers",
+ reverse => 1,
);
my $p = 0;
for (@{$l})
{
- $p += $_->{numplayers}
+ $p += $_->{numplayers};
+ last unless $_->{numplayers}
}
- # return json data as the response
- my $json_data = encode_json [{motd => $html}, {total => $s, players => $p}];
- print { $self->resFd() } $json_data;
-
- # set content type and allow off-domain access (for example jQuery)
+ # response as json data
$self->resHeader("Access-Control-Allow-Origin", "*");
- $self->resHeader("Content-Type", "application/json; charset=UTF-8");
+ $self->resJSON([
+ {motd => $html},
+ {total => $s, players => $p}
+ ]);
+
}
1;