Add core grpc server

This commit is contained in:
problematicconsumer
2024-03-15 11:43:13 +03:30
parent e39d9e6fdb
commit 086b5208c0
11 changed files with 553 additions and 42 deletions

View File

@@ -10,6 +10,7 @@ import io.nekohasekai.libbox.Libbox
import io.nekohasekai.mobile.Mobile
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
@@ -22,6 +23,7 @@ class MethodHandler(private val scope: CoroutineScope) : FlutterPlugin,
const val channelName = "com.hiddify.app/method"
enum class Trigger(val method: String) {
Setup("setup"),
ParseConfig("parse_config"),
ChangeConfigOptions("change_config_options"),
GenerateConfig("generate_config"),
@@ -49,6 +51,15 @@ class MethodHandler(private val scope: CoroutineScope) : FlutterPlugin,
override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
when (call.method) {
Trigger.Setup.method -> {
GlobalScope.launch {
result.runCatching {
Mobile.setup()
success("")
}
}
}
Trigger.ParseConfig.method -> {
scope.launch(Dispatchers.IO) {
result.runCatching {