feat: moved from JSON objects of metrics to simplified strings for the Stats Remote

This commit is contained in:
Serhiy Mytrovtsiy
2025-04-05 22:54:01 +02:00
parent d2688a35b2
commit f524f86429
8 changed files with 98 additions and 44 deletions

View File

@@ -68,7 +68,7 @@ public struct Bandwidth: Codable {
var download: Int64 = 0
}
public struct Network_Usage: Codable {
public struct Network_Usage: Codable, RemoteType {
var bandwidth: Bandwidth = Bandwidth()
var total: Bandwidth = Bandwidth()
@@ -92,6 +92,12 @@ public struct Network_Usage: Codable {
self.wifiDetails.reset()
}
public func remote() -> Data? {
let addr = "\(self.laddr.v4 ?? ""),\(self.laddr.v6 ?? ""),\(self.raddr.v4 ?? ""),\(self.raddr.v6 ?? "")"
let string = "1,\(self.interface?.BSDName ?? ""),1,\(self.bandwidth.download),\(self.bandwidth.upload),\(addr)$"
return string.data(using: .utf8)
}
}
public struct Network_Connectivity: Codable {