mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-13 11:53:41 +00:00
feat: move native communication to FFI (#1457)
This commit is contained in:
86 files changed
+4558
-886
No files matched your search
@@ -0,0 +1,35 @@
|
||||
#import "GopeedTaskEventForwarder.h"
|
||||
|
||||
#import <Libgopeed/Libgopeed.h>
|
||||
|
||||
@interface GopeedTaskEventForwarder () <LibgopeedTaskEventListener>
|
||||
|
||||
@property(nonatomic, strong) FlutterMethodChannel *channel;
|
||||
|
||||
@end
|
||||
|
||||
@implementation GopeedTaskEventForwarder
|
||||
|
||||
- (instancetype)initWithChannel:(FlutterMethodChannel *)channel {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_channel = channel;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)onTaskEvent:(NSString * _Nullable)payload {
|
||||
NSString *arguments = payload ?: @"";
|
||||
FlutterMethodChannel *channel = self.channel;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[channel invokeMethod:@"taskEvent" arguments:arguments];
|
||||
});
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
void GopeedSubscribeTaskEventsWithForwarder(
|
||||
int64_t mask,
|
||||
GopeedTaskEventForwarder * _Nullable listener) {
|
||||
LibgopeedSubscribeTaskEvents(mask, listener);
|
||||
}
|
||||
Reference in new issue
Block a user