Skip to content

Commit

Permalink
Web load last 60s and 60m stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Jun 28, 2024
1 parent 2b91b1c commit 14d6278
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
12 changes: 12 additions & 0 deletions apps/web/src/routes/(app)/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@
updateHardwareStats(WSData.data)
}
}
if (WSData.type == "secondsData") {
for (let i = 0; i < 3; i++) {
updateHardwareStats(WSData.data)
}
}
if (WSData.type == "minutesData") {
for (let i = 0; i < 3; i++) {
$hardwareStatistics.minutes.push(generateSecondsData(WSData.data))
}
}
})
}
</script>
17 changes: 16 additions & 1 deletion platforms/windows/service/RTCServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using lib;
using SIPSorcery.Net;
using System.Text.Json;
using System.Text.Json.Nodes;

namespace service;
public class RTCServer {
Expand All @@ -14,8 +15,22 @@ public void Start(HardwareInfo hardwareInfo) {
EzRTCHost.Start();
});
EzRTCHost.dataChannelOpen += (data) => {
EzRTCHost.dataChannelOpen += (RTCDataChannel data) => {
EzRTCHost.sendMessageToAll(JsonSerializer.Serialize(new GenericMessage<API>() { Type = "initialData", Data = hardwareInfo.API }, Program.CompressedSerializerOptions));
if (data.readyState == RTCDataChannelState.open) {
var secondsList = Program.HardwareStats.seconds.Where((x, i) => (i + 1) % 3 == 0).ToList();
for (int i = 0; i < secondsList.Count; i++) {
data.send(JsonSerializer.Serialize(new GenericMessage<JsonNode>() { Type = "secondsData", Data = JsonNode.Parse(secondsList[i]) }, Program.CompressedSerializerOptions));
}
var minutesList = Program.HardwareStats.minutes.Where((x, i) => (i + 1) % 3 == 0).ToList();
for (int i = 0; i < minutesList.Count; i++) {
data.send(JsonSerializer.Serialize(new GenericMessage<JsonNode>() { Type = "minutesData", Data = JsonNode.Parse(minutesList[i]) }, Program.CompressedSerializerOptions));
}
}
};
EzRTCHost.dataChannelMessage += (data) => {
Expand Down

0 comments on commit 14d6278

Please sign in to comment.