初始化提交
This commit is contained in:
+50
@@ -0,0 +1,50 @@
|
||||
import Foundation
|
||||
import Combine
|
||||
import Libcore
|
||||
|
||||
public class KRActiveGroupsEventHandler: NSObject, FlutterPlugin, FlutterStreamHandler {
|
||||
|
||||
|
||||
static let name = "\(Bundle.main.serviceIdentifier)/active-groups"
|
||||
private var commandClient: CommandClient?
|
||||
private var channel: FlutterEventChannel?
|
||||
private var events: FlutterEventSink?
|
||||
private var cancellable: AnyCancellable?
|
||||
|
||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||
let instance = KRActiveGroupsEventHandler()
|
||||
instance.channel = FlutterEventChannel(name: Self.name,
|
||||
binaryMessenger: registrar.messenger())
|
||||
instance.channel?.setStreamHandler(instance)
|
||||
}
|
||||
|
||||
public func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? {
|
||||
FileManager.default.changeCurrentDirectoryPath(FilePath.sharedDirectory.path)
|
||||
self.events = events
|
||||
commandClient = CommandClient(.groupsInfoOnly)
|
||||
commandClient?.connect()
|
||||
cancellable = commandClient?.$groups.sink{ [self] sbGroups in
|
||||
self.kr_writeGroups(sbGroups)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
public func onCancel(withArguments arguments: Any?) -> FlutterError? {
|
||||
commandClient?.disconnect()
|
||||
cancellable?.cancel()
|
||||
events = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func kr_writeGroups(_ sbGroups: [SBGroup]?) {
|
||||
guard let sbGroups else {return}
|
||||
if
|
||||
let groups = try? JSONEncoder().encode(sbGroups),
|
||||
let groups = String(data: groups, encoding: .utf8)
|
||||
{
|
||||
DispatchQueue.main.async { [events = self.events, groups] () in
|
||||
events?(groups)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
//
|
||||
// AlertEventHandler.swift
|
||||
// Runner
|
||||
//
|
||||
// Created by GFWFighter on 10/24/23.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Combine
|
||||
|
||||
public class KRAlertsEventHandler: NSObject, FlutterPlugin, FlutterStreamHandler {
|
||||
static let name = "\(Bundle.main.serviceIdentifier)/service.alerts"
|
||||
|
||||
private var channel: FlutterEventChannel?
|
||||
|
||||
private var cancellable: AnyCancellable?
|
||||
|
||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||
let instance = KRAlertsEventHandler()
|
||||
instance.channel = FlutterEventChannel(name: Self.name, binaryMessenger: registrar.messenger(), codec: FlutterJSONMethodCodec())
|
||||
instance.channel?.setStreamHandler(instance)
|
||||
}
|
||||
|
||||
public func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? {
|
||||
cancellable = VPNManager.shared.$alert.sink { [events] alert in
|
||||
var data = [
|
||||
"status": "Stopped",
|
||||
"alert": alert.alert?.rawValue,
|
||||
"message": alert.message,
|
||||
]
|
||||
for key in data.keys {
|
||||
if data[key] == nil {
|
||||
data.removeValue(forKey: key)
|
||||
}
|
||||
}
|
||||
events(data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
public func onCancel(withArguments arguments: Any?) -> FlutterError? {
|
||||
cancellable?.cancel()
|
||||
return nil
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
//
|
||||
// FileMethodHandler.swift
|
||||
// Runner
|
||||
//
|
||||
// Created by GFWFighter on 10/23/23.
|
||||
//
|
||||
|
||||
import Flutter
|
||||
import Combine
|
||||
import Libcore
|
||||
|
||||
public class KRFileMethodHandler: NSObject, FlutterPlugin {
|
||||
public static let name = "\(Bundle.main.serviceIdentifier)/file"
|
||||
|
||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||
let channel = FlutterMethodChannel(name: Self.name, binaryMessenger: registrar.messenger())
|
||||
let instance = KRFileMethodHandler()
|
||||
registrar.addMethodCallDelegate(instance, channel: channel)
|
||||
instance.channel = channel
|
||||
}
|
||||
|
||||
private var channel: FlutterMethodChannel?
|
||||
|
||||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
switch call.method {
|
||||
case "get_paths":
|
||||
result(kr_getPaths(args: call.arguments))
|
||||
default:
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
}
|
||||
|
||||
public func kr_getPaths(args: Any?) -> [String:String] {
|
||||
return [
|
||||
"base": FilePath.sharedDirectory.path,
|
||||
"working": FilePath.workingDirectory.path,
|
||||
"temp": FilePath.cacheDirectory.path
|
||||
]
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
import Foundation
|
||||
import Combine
|
||||
import Libcore
|
||||
|
||||
public class KRGroupsEventHandler: NSObject, FlutterPlugin, FlutterStreamHandler{
|
||||
|
||||
static let name = "\(Bundle.main.serviceIdentifier)/groups"
|
||||
|
||||
private var commandClient: CommandClient?
|
||||
private var channel: FlutterEventChannel?
|
||||
private var events: FlutterEventSink?
|
||||
private var cancellable: AnyCancellable?
|
||||
|
||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||
let instance = KRGroupsEventHandler()
|
||||
instance.channel = FlutterEventChannel(name: Self.name,
|
||||
binaryMessenger: registrar.messenger())
|
||||
instance.channel?.setStreamHandler(instance)
|
||||
}
|
||||
|
||||
public func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? {
|
||||
FileManager.default.changeCurrentDirectoryPath(FilePath.sharedDirectory.path)
|
||||
self.events = events
|
||||
commandClient = CommandClient(.groups)
|
||||
commandClient?.connect()
|
||||
cancellable = commandClient?.$groups.sink{ [self] groups in
|
||||
self.kr_writeGroups(groups)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
public func onCancel(withArguments arguments: Any?) -> FlutterError? {
|
||||
commandClient?.disconnect()
|
||||
cancellable?.cancel()
|
||||
events = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func kr_writeGroups(_ sbGroups: [SBGroup]?) {
|
||||
guard let sbGroups else {return}
|
||||
if
|
||||
let groups = try? JSONEncoder().encode(sbGroups),
|
||||
let groups = String(data: groups, encoding: .utf8)
|
||||
{
|
||||
DispatchQueue.main.async { [events = self.events, groups] in
|
||||
events?(groups)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
import Foundation
|
||||
import Combine
|
||||
import Libcore
|
||||
|
||||
class KRLogsEventHandler: NSObject, FlutterPlugin, FlutterStreamHandler {
|
||||
static let name = "\(Bundle.main.serviceIdentifier)/service.logs"
|
||||
|
||||
private var commandClient: CommandClient?
|
||||
private var events: FlutterEventSink?
|
||||
private var channel: FlutterEventChannel?
|
||||
private var cancellable: AnyCancellable?
|
||||
|
||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||
let instance = KRLogsEventHandler()
|
||||
instance.channel = FlutterEventChannel(name: Self.name,
|
||||
binaryMessenger: registrar.messenger())
|
||||
instance.channel?.setStreamHandler(instance)
|
||||
}
|
||||
|
||||
public func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? {
|
||||
FileManager.default.changeCurrentDirectoryPath(FilePath.sharedDirectory.path)
|
||||
self.events = events
|
||||
commandClient = CommandClient(.log)
|
||||
commandClient?.connect()
|
||||
cancellable = commandClient?.$logList.sink{ [self] logs in
|
||||
events(logs)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
public func onCancel(withArguments arguments: Any?) -> FlutterError? {
|
||||
commandClient?.disconnect()
|
||||
cancellable?.cancel()
|
||||
events = nil
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
extension KRLogsEventHandler {
|
||||
public func kr_clearLog() {}
|
||||
public func kr_connected() {}
|
||||
public func kr_disconnected(_ message: String?) {}
|
||||
public func kr_initializeClashMode(_ modeList: LibboxStringIteratorProtocol?, currentMode: String?) {}
|
||||
public func kr_updateClashMode(_ newMode: String?) {}
|
||||
public func kr_writeGroups(_ message: LibboxOutboundGroupIteratorProtocol?) {}
|
||||
public func kr_writeStatus(_ message: LibboxStatusMessage?) {}
|
||||
}
|
||||
*/
|
||||
Executable
+232
@@ -0,0 +1,232 @@
|
||||
//
|
||||
// MethodHandler.swift
|
||||
// Runner
|
||||
//
|
||||
// Created by GFWFighter on 10/23/23.
|
||||
//
|
||||
|
||||
import Flutter
|
||||
import Combine
|
||||
import Libcore
|
||||
|
||||
public class KRMethodHandler: NSObject, FlutterPlugin {
|
||||
|
||||
private var cancelBag: Set<AnyCancellable> = []
|
||||
// 通常在类的属性中定义
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
public static let name = "\(Bundle.main.serviceIdentifier)/method"
|
||||
|
||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||
let channel = FlutterMethodChannel(name: Self.name, binaryMessenger: registrar.messenger())
|
||||
let instance = KRMethodHandler()
|
||||
registrar.addMethodCallDelegate(instance, channel: channel)
|
||||
instance.channel = channel
|
||||
}
|
||||
|
||||
private var channel: FlutterMethodChannel?
|
||||
|
||||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
@Sendable func kr_mainResult(_ res: Any?) async -> Void {
|
||||
await MainActor.run {
|
||||
result(res)
|
||||
}
|
||||
}
|
||||
|
||||
switch call.method {
|
||||
case "parse_config":
|
||||
guard
|
||||
let args = call.arguments as? [String:Any?],
|
||||
let path = args["path"] as? String,
|
||||
let tempPath = args["tempPath"] as? String,
|
||||
let debug = (args["debug"] as? NSNumber)?.boolValue
|
||||
else {
|
||||
result(FlutterError(code: "INVALID_ARGS", message: nil, details: nil))
|
||||
return
|
||||
}
|
||||
var error: NSError?
|
||||
MobileParse(path, tempPath, debug, &error)
|
||||
if let error {
|
||||
result(FlutterError(code: String(error.code), message: error.description, details: nil))
|
||||
return
|
||||
}
|
||||
result("")
|
||||
case "change_hiddify_options":
|
||||
guard let options = call.arguments as? String else {
|
||||
result(FlutterError(code: "INVALID_ARGS", message: nil, details: nil))
|
||||
return
|
||||
}
|
||||
VPNConfig.shared.configOptions = options
|
||||
result(true)
|
||||
case "setup":
|
||||
Task {
|
||||
do {
|
||||
try await VPNManager.shared.setup()
|
||||
} catch {
|
||||
await kr_mainResult(FlutterError(code: "SETUP", message: error.localizedDescription, details: nil))
|
||||
return
|
||||
}
|
||||
await kr_mainResult(true)
|
||||
}
|
||||
case "start":
|
||||
Task {
|
||||
guard
|
||||
let args = call.arguments as? [String:Any?],
|
||||
let path = args["path"] as? String
|
||||
else {
|
||||
await kr_mainResult(FlutterError(code: "INVALID_ARGS", message: nil, details: nil))
|
||||
return
|
||||
}
|
||||
VPNConfig.shared.activeConfigPath = path
|
||||
|
||||
|
||||
var error: NSError?
|
||||
let config = MobileBuildConfig(path, VPNConfig.shared.configOptions, &error)
|
||||
print(config);
|
||||
if let error {
|
||||
await kr_mainResult(FlutterError(code: String(error.code), message: error.description, details: nil))
|
||||
return
|
||||
}
|
||||
do {
|
||||
try await VPNManager.shared.setup()
|
||||
try await VPNManager.shared.connect(with: config, disableMemoryLimit: VPNConfig.shared.disableMemoryLimit)
|
||||
} catch {
|
||||
await kr_mainResult(FlutterError(code: "SETUP_CONNECTION", message: error.localizedDescription, details: nil))
|
||||
return
|
||||
}
|
||||
await kr_mainResult(true)
|
||||
}
|
||||
case "restart":
|
||||
|
||||
Task { [unowned self] in
|
||||
guard
|
||||
let args = call.arguments as? [String:Any?],
|
||||
let path = args["path"] as? String
|
||||
else {
|
||||
await kr_mainResult(FlutterError(code: "INVALID_ARGS", message: nil, details: nil))
|
||||
return
|
||||
}
|
||||
VPNConfig.shared.activeConfigPath = path
|
||||
|
||||
|
||||
VPNManager.shared.disconnect()
|
||||
|
||||
do {
|
||||
try await kr_waitForStop().value
|
||||
} catch {
|
||||
await kr_mainResult(FlutterError(code: "SETUP_CONNECTION", message: error.localizedDescription, details: nil))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
var error: NSError?
|
||||
let config = MobileBuildConfig(path, VPNConfig.shared.configOptions, &error)
|
||||
|
||||
|
||||
if let error {
|
||||
await kr_mainResult(FlutterError(code: "BUILD_CONFIG", message: error.localizedDescription, details: nil))
|
||||
return
|
||||
}
|
||||
do {
|
||||
try await VPNManager.shared.setup()
|
||||
try await VPNManager.shared.connect(with: config, disableMemoryLimit: VPNConfig.shared.disableMemoryLimit)
|
||||
} catch {
|
||||
await kr_mainResult(FlutterError(code: "SETUP_CONNECTION", message: error.localizedDescription, details: nil))
|
||||
return
|
||||
}
|
||||
await kr_mainResult(true)
|
||||
}
|
||||
case "stop":
|
||||
VPNManager.shared.disconnect()
|
||||
result(true)
|
||||
case "reset":
|
||||
VPNManager.shared.reset()
|
||||
result(true)
|
||||
case "url_test":
|
||||
guard
|
||||
let args = call.arguments as? [String:Any?]
|
||||
else {
|
||||
result(FlutterError(code: "INVALID_ARGS", message: nil, details: nil))
|
||||
return
|
||||
}
|
||||
let group = args["groupTag"] as? String
|
||||
FileManager.default.changeCurrentDirectoryPath(FilePath.sharedDirectory.path)
|
||||
do {
|
||||
try LibboxNewStandaloneCommandClient()?.urlTest(group)
|
||||
} catch {
|
||||
result(FlutterError(code: "URL_TEST", message: error.localizedDescription, details: nil))
|
||||
return
|
||||
}
|
||||
result(true)
|
||||
case "select_outbound":
|
||||
guard
|
||||
let args = call.arguments as? [String:Any?],
|
||||
let group = args["groupTag"] as? String,
|
||||
let outbound = args["outboundTag"] as? String
|
||||
else {
|
||||
result(FlutterError(code: "INVALID_ARGS", message: nil, details: nil))
|
||||
return
|
||||
}
|
||||
FileManager.default.changeCurrentDirectoryPath(FilePath.sharedDirectory.path)
|
||||
do {
|
||||
try LibboxNewStandaloneCommandClient()?.selectOutbound(group, outboundTag: outbound)
|
||||
} catch {
|
||||
result(FlutterError(code: "SELECT_OUTBOUND", message: error.localizedDescription, details: nil))
|
||||
return
|
||||
}
|
||||
result(true)
|
||||
case "generate_config":
|
||||
guard
|
||||
let args = call.arguments as? [String:Any?],
|
||||
let path = args["path"] as? String
|
||||
else {
|
||||
result(FlutterError(code: "INVALID_ARGS", message: nil, details: nil))
|
||||
return
|
||||
}
|
||||
var error: NSError?
|
||||
let config = MobileBuildConfig(path, VPNConfig.shared.configOptions, &error)
|
||||
if let error {
|
||||
result(FlutterError(code: "BUILD_CONFIG", message: error.localizedDescription, details: nil))
|
||||
return
|
||||
}
|
||||
result(config)
|
||||
case "generate_warp_config":
|
||||
guard let args = call.arguments as? [String: Any],
|
||||
let licenseKey = args["license-key"] as? String,
|
||||
let accountId = args["previous-account-id"] as? String,
|
||||
let accessToken = args["previous-access-token"] as? String else {
|
||||
result(FlutterError(code: "INVALID_ARGS", message: nil, details: nil))
|
||||
return
|
||||
}
|
||||
let warpConfig = MobileGenerateWarpConfig(licenseKey, accountId, accessToken, nil)
|
||||
result(warpConfig)
|
||||
default:
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
}
|
||||
|
||||
private func kr_waitForStop(timeout: TimeInterval = 1) -> Future<Void, Error> {
|
||||
Future { promise in
|
||||
print("开始等待 VPN 停止...")
|
||||
|
||||
let timeoutTimer = Timer.scheduledTimer(withTimeInterval: timeout, repeats: false) { _ in
|
||||
promise(.failure(NSError(domain: "VPNError", code: -1, userInfo: [NSLocalizedDescriptionKey: "等待 VPN 停止超时"])))
|
||||
}
|
||||
|
||||
VPNManager.shared.$state
|
||||
.handleEvents(receiveSubscription: { _ in
|
||||
print("订阅状态变化")
|
||||
}, receiveOutput: { state in
|
||||
print("当前 VPN 状态: \(state)")
|
||||
})
|
||||
.filter { $0 == .disconnected }
|
||||
.first()
|
||||
.delay(for: 0.5, scheduler: DispatchQueue.main)
|
||||
.sink { _ in
|
||||
timeoutTimer.invalidate()
|
||||
print("VPN 已停止")
|
||||
promise(.success(()))
|
||||
}
|
||||
.store(in: &self.cancellables)
|
||||
}
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
//
|
||||
// PlatformMethodHandler.swift
|
||||
// Runner
|
||||
//
|
||||
// Created by Hiddify on 12/27/23.
|
||||
//
|
||||
|
||||
import Flutter
|
||||
import Combine
|
||||
import Libcore
|
||||
|
||||
public class KRPlatformMethodHandler: NSObject, FlutterPlugin {
|
||||
|
||||
public static let name = "\(Bundle.main.serviceIdentifier)/platform"
|
||||
|
||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||
let channel = FlutterMethodChannel(name: Self.name, binaryMessenger: registrar.messenger())
|
||||
let instance = KRPlatformMethodHandler()
|
||||
registrar.addMethodCallDelegate(instance, channel: channel)
|
||||
instance.channel = channel
|
||||
}
|
||||
|
||||
private var channel: FlutterMethodChannel?
|
||||
|
||||
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
||||
switch call.method {
|
||||
case "get_paths":
|
||||
result(kr_getPaths(args: call.arguments))
|
||||
default:
|
||||
result(FlutterMethodNotImplemented)
|
||||
}
|
||||
}
|
||||
|
||||
public func kr_getPaths(args: Any?) -> [String:String] {
|
||||
return [
|
||||
"base": FilePath.sharedDirectory.path,
|
||||
"working": FilePath.workingDirectory.path,
|
||||
"temp": FilePath.cacheDirectory.path
|
||||
]
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
import Foundation
|
||||
import Flutter
|
||||
import Combine
|
||||
import Libcore
|
||||
|
||||
public class KRStatsEventHandler: NSObject, FlutterPlugin, FlutterStreamHandler {
|
||||
|
||||
static let name = "\(Bundle.main.serviceIdentifier)/stats"
|
||||
|
||||
private var commandClient: CommandClient?
|
||||
private var channel: FlutterEventChannel?
|
||||
private var events: FlutterEventSink?
|
||||
private var cancellable: AnyCancellable?
|
||||
|
||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||
let instance = KRStatsEventHandler()
|
||||
instance.channel = FlutterEventChannel(name: Self.name,
|
||||
binaryMessenger: registrar.messenger(),
|
||||
codec: FlutterJSONMethodCodec())
|
||||
instance.channel?.setStreamHandler(instance)
|
||||
}
|
||||
|
||||
public func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? {
|
||||
FileManager.default.changeCurrentDirectoryPath(FilePath.sharedDirectory.path)
|
||||
self.events = events
|
||||
commandClient = CommandClient(.status)
|
||||
commandClient?.connect()
|
||||
cancellable = commandClient?.$status.sink{ [self] status in
|
||||
self.kr_writeStatus(status)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
public func onCancel(withArguments arguments: Any?) -> FlutterError? {
|
||||
commandClient?.disconnect()
|
||||
cancellable?.cancel()
|
||||
events = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func kr_writeStatus(_ message: LibboxStatusMessage?) {
|
||||
guard let message else { return }
|
||||
|
||||
let data = [
|
||||
"connections-in": message.connectionsIn,
|
||||
"connections-out": message.connectionsOut,
|
||||
"uplink": message.uplink,
|
||||
"downlink": message.downlink,
|
||||
"uplink-total": message.uplinkTotal,
|
||||
"downlink-total": message.downlinkTotal
|
||||
] as [String:Any]
|
||||
events?(data)
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// StatusEventHandler.swift
|
||||
// Runner
|
||||
//
|
||||
// Created by GFWFighter on 10/24/23.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Combine
|
||||
|
||||
public class KRStatusEventHandler: NSObject, FlutterPlugin, FlutterStreamHandler {
|
||||
static let name = "\(Bundle.main.serviceIdentifier)/service.status"
|
||||
|
||||
private var channel: FlutterEventChannel?
|
||||
|
||||
private var cancellable: AnyCancellable?
|
||||
|
||||
public static func register(with registrar: FlutterPluginRegistrar) {
|
||||
let instance = KRStatusEventHandler()
|
||||
instance.channel = FlutterEventChannel(name: Self.name, binaryMessenger: registrar.messenger(), codec: FlutterJSONMethodCodec())
|
||||
instance.channel?.setStreamHandler(instance)
|
||||
}
|
||||
|
||||
public func onListen(withArguments arguments: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? {
|
||||
cancellable = VPNManager.shared.$state.sink { [events] status in
|
||||
switch status {
|
||||
case .reasserting, .connecting:
|
||||
events(["status": "Starting"])
|
||||
case .connected:
|
||||
events(["status": "Started"])
|
||||
case .disconnecting:
|
||||
events(["status": "Stopping"])
|
||||
case .disconnected, .invalid:
|
||||
events(["status": "Stopped"])
|
||||
@unknown default:
|
||||
events(["status": "Stopped"])
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
public func onCancel(withArguments arguments: Any?) -> FlutterError? {
|
||||
cancellable?.cancel()
|
||||
return nil
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user