initializeV2Ray method

  1. @override
Future<void> initializeV2Ray({
  1. required void onStatusChanged(
    1. V2RayStatus status
    ),
  2. required String notificationIconResourceType,
  3. required String notificationIconResourceName,
})
override

Implementation

@override
Future<void> initializeV2Ray({
  required void Function(V2RayStatus status) onStatusChanged,
  required String notificationIconResourceType,
  required String notificationIconResourceName,
}) async {
  eventChannel.receiveBroadcastStream().distinct().cast().listen((event) {
    if (event != null) {
      onStatusChanged.call(V2RayStatus(
        duration: event[0],
        uploadSpeed: int.parse(event[1]),
        downloadSpeed: int.parse(event[2]),
        upload: int.parse(event[3]),
        download: int.parse(event[4]),
        state: event[5],
      ));
    }
  });
  await methodChannel.invokeMethod(
    'initializeV2Ray',
    {
      "notificationIconResourceType": notificationIconResourceType,
      "notificationIconResourceName": notificationIconResourceName,
    },
  );
}