Implement /api/get_bottleneck_stats

This commit is contained in:
Lauri Kasanen
2021-07-26 18:58:29 +03:00
parent 811e7cde3a
commit 32e8d40472
9 changed files with 122 additions and 5 deletions

View File

@@ -63,7 +63,7 @@ namespace rfb {
const size_t* lengths,
const rdr::U8* const* data);
virtual void sendStats() = 0;
virtual void sendStats(const bool toClient = true) = 0;
virtual bool canChangeKasmSettings() const = 0;

View File

@@ -17,6 +17,7 @@
* USA.
*/
#include <network/GetAPI.h>
#include <network/TcpSocket.h>
#include <rfb/ComparingUpdateTracker.h>
@@ -1459,7 +1460,7 @@ static void pruneStatList(std::list<struct timeval> &list, const struct timeval
}
}
void VNCSConnectionST::sendStats() {
void VNCSConnectionST::sendStats(const bool toClient) {
char buf[1024];
struct timeval now;
@@ -1498,8 +1499,12 @@ void VNCSConnectionST::sendStats() {
#undef ten
vlog.info("Sending client stats:\n%s\n", buf);
writer()->writeStats(buf, strlen(buf));
if (toClient) {
vlog.info("Sending client stats:\n%s\n", buf);
writer()->writeStats(buf, strlen(buf));
} else if (server->apimessager) {
server->apimessager->mainUpdateBottleneckStats(peerEndpoint.buf, buf);
}
}
// setCursor() is called whenever the cursor has changed shape or pixel format.

View File

@@ -164,6 +164,8 @@ namespace rfb {
void setStatus(int status);
int getStatus();
virtual void sendStats(const bool toClient = true);
private:
// SConnection callbacks
@@ -191,7 +193,6 @@ namespace rfb {
virtual void supportsContinuousUpdates();
virtual void supportsLEDState();
virtual void sendStats();
virtual bool canChangeKasmSettings() const {
return (accessRights & (AccessPtrEvents | AccessKeyEvents)) ==
(AccessPtrEvents | AccessKeyEvents);

View File

@@ -997,6 +997,9 @@ void VNCServerST::writeUpdate()
(*ci)->add_copypassed(ui.copypassed);
(*ci)->add_changed(ui.changed);
(*ci)->writeFramebufferUpdateOrClose();
if (apimessager)
(*ci)->sendStats(false);
}
}