]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commit - index.php
Add api/common_api.php and use Server-Sent Events, streaming JSON
authorBram Matthys <redacted>
Wed, 12 Apr 2023 10:02:09 +0000 (12:02 +0200)
committerBram Matthys <redacted>
Wed, 12 Apr 2023 10:04:10 +0000 (12:04 +0200)
commitfd4848e4bc329f633c8faf725f9d4faef27ca54c
treed1b85c38399d0a424d87d95ff73ef2ab965e7f98
parent512ddbd1274d017e44bf356e55c39aead9333b5d
Add api/common_api.php and use Server-Sent Events, streaming JSON
data on like the overview page to update the User/Channel/.. counts
instead of doing a HTTP request every second like we had before.

The use of api/common_api.php from api/ is quite easy:
require_once('common_api.php');
which takes care of validating the session, closing the session,
disabling output buffering, etc.

And then you use either:
* api_log_loop($sources)
  like: api_log_loop(["connect"]);
Or:
* api_timer_loop((int $every_msec, string $method, array|null $params = null)
  like: api_timer_loop(1000, "stats.get");

And then all the (streaming) JSON-RPC response data from the server is
streamed back to the client via SSE.
api/common_api.php [new file with mode: 0644]
api/overview.php
index.php