diff options
| author | Darkelarious <darkelarious@333networks.com> | 2022-08-07 17:58:59 +0200 |
|---|---|---|
| committer | Darkelarious <darkelarious@333networks.com> | 2022-08-07 17:58:59 +0200 |
| commit | 1ca9cdc52f3b63c8bf5e4550bbb922608beb437f (patch) | |
| tree | 90802c7f7800c1b9d2d5d22f0e6b41b373ec39b9 /lib/MasterWebInterface/Handler/Json/Motd.pm | |
| parent | e9b4cd5fc79ca2d044eba4fed8bf62b138f44249 (diff) | |
| download | WebInterface-Perl-1ca9cdc52f3b63c8bf5e4550bbb922608beb437f.tar.gz WebInterface-Perl-1ca9cdc52f3b63c8bf5e4550bbb922608beb437f.zip | |
fixes in Json API
Diffstat (limited to 'lib/MasterWebInterface/Handler/Json/Motd.pm')
| -rwxr-xr-x | lib/MasterWebInterface/Handler/Json/Motd.pm | 20 |
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; |
