Skip to content

Any way to get statistics for amount of data sent to each client? #3943

Answered by darrachequesne
stodge asked this question in Q&A
Discussion options

You must be logged in to vote

Hmm, there is currently no built-in way to do that. You could listen to the packetCreate event:

socket.conn.on("packetCreate", (packet) => {
  if (packet.data) {
    socket.totalAmount += Buffer.byteLength(packet.data);
  }
});

Though it might not represent the actual amount, since the payload can then be compressed down the line (it should be OK for WebSocket connections though, if the permessage-deflate extension is disabled, which is the default).

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by darrachequesne
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants