Fix ios stats

This commit is contained in:
problematicconsumer
2024-01-18 23:07:29 +03:30
parent 98fca5792a
commit 17d8719d6e
2 changed files with 6 additions and 8 deletions

View File

@@ -28,7 +28,7 @@ public class StatsEventHandler: NSObject, FlutterPlugin, FlutterStreamHandler, L
self.events = events self.events = events
let opts = LibboxCommandClientOptions() let opts = LibboxCommandClientOptions()
opts.command = LibboxCommandStatus opts.command = LibboxCommandStatus
opts.statusInterval = 300 opts.statusInterval = Int64(NSEC_PER_SEC)
commandClient = LibboxCommandClient(self, options: opts) commandClient = LibboxCommandClient(self, options: opts)
try? commandClient?.connect() try? commandClient?.connect()
return nil return nil
@@ -51,11 +51,7 @@ public class StatsEventHandler: NSObject, FlutterPlugin, FlutterStreamHandler, L
"uplink-total": message.uplinkTotal, "uplink-total": message.uplinkTotal,
"downlink-total": message.downlinkTotal "downlink-total": message.downlinkTotal
] as [String:Any] ] as [String:Any]
guard events?(data)
let json = try? JSONSerialization.data(withJSONObject: data),
let json = String(data: json, encoding: .utf8)
else { return }
events?(json)
} }
} }

View File

@@ -194,7 +194,9 @@ class PlatformSingboxService with InfraLogger implements SingboxService {
if (event case Map<String, dynamic> _) { if (event case Map<String, dynamic> _) {
return SingboxStats.fromJson(event); return SingboxStats.fromJson(event);
} }
loggy.error("[stats client] unexpected type, msg: $event"); loggy.error(
"[stats client] unexpected type(${event.runtimeType}), msg: $event",
);
throw "invalid type"; throw "invalid type";
}, },
); );