Change proxies flow

This commit is contained in:
problematicconsumer
2023-08-29 19:32:31 +03:30
parent 375cb8a945
commit e8eb55ac8d
15 changed files with 335 additions and 229 deletions

View File

@@ -67,12 +67,53 @@ class MobileSingboxService with InfraLogger implements SingboxService {
);
}
@override
Stream<String> watchOutbounds() {
const channel = EventChannel("com.hiddify.app/groups");
loggy.debug("watching outbounds");
return channel.receiveBroadcastStream().map(
(event) {
if (event case String _) {
return event;
}
throw "invalid type";
},
);
}
@override
Stream<String> watchStatus() {
// TODO: implement watchStatus
return const Stream.empty();
}
@override
TaskEither<String, Unit> selectOutbound(String groupTag, String outboundTag) {
return TaskEither(
() async {
loggy.debug("selecting outbound");
await _methodChannel.invokeMethod(
"select_outbound",
{"groupTag": groupTag, "outboundTag": outboundTag},
);
return right(unit);
},
);
}
@override
TaskEither<String, Unit> urlTest(String groupTag) {
return TaskEither(
() async {
await _methodChannel.invokeMethod(
"url_test",
{"groupTag": groupTag},
);
return right(unit);
},
);
}
@override
Stream<String> watchLogs(String path) {
return _logsChannel.receiveBroadcastStream().map(