You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.7 KiB
50 lines
1.7 KiB
import Flutter
|
|
import UIKit
|
|
|
|
/// Flutter entry point — mirrors the Android `JielihomePlugin.kt`.
|
|
///
|
|
/// Responsibilities (kept symmetric with Android):
|
|
/// 1. Bind `device_jieli/method` MethodChannel to [MethodRouter];
|
|
/// 2. Bind `device_jieli/event` EventChannel to the shared [EventDispatcher];
|
|
/// 3. Register the JieLi vendor with the device-manager native registry
|
|
/// (placeholder until [JieliNativeDevicePlugin.register] is wired).
|
|
///
|
|
/// All actual business logic lives in [JieliHomeServer] and the feature/event
|
|
/// submodules under `Classes/Feature/`.
|
|
public class JielihomePlugin: NSObject, FlutterPlugin {
|
|
|
|
private var methodChannel: FlutterMethodChannel?
|
|
private var eventChannel: FlutterEventChannel?
|
|
private var router: MethodRouter?
|
|
|
|
public static func register(with registrar: FlutterPluginRegistrar) {
|
|
let instance = JielihomePlugin()
|
|
instance.attach(registrar: registrar)
|
|
}
|
|
|
|
private func attach(registrar: FlutterPluginRegistrar) {
|
|
let server = JieliHomeServer.shared
|
|
let router = MethodRouter(server: server)
|
|
self.router = router
|
|
|
|
let methodChannel = FlutterMethodChannel(
|
|
name: "device_jieli/method",
|
|
binaryMessenger: registrar.messenger()
|
|
)
|
|
methodChannel.setMethodCallHandler { call, result in
|
|
router.handle(call: call, result: result)
|
|
}
|
|
self.methodChannel = methodChannel
|
|
|
|
let eventChannel = FlutterEventChannel(
|
|
name: "device_jieli/event",
|
|
binaryMessenger: registrar.messenger()
|
|
)
|
|
eventChannel.setStreamHandler(server.dispatcher)
|
|
self.eventChannel = eventChannel
|
|
|
|
// Vendor registration with the device-manager registry. Symmetric to
|
|
// Android's `JieliNativeDevicePlugin.register(...)`.
|
|
JieliNativeDevicePlugin.register()
|
|
}
|
|
}
|
|
|