-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'proxy-session' into develop
- Loading branch information
Showing
18 changed files
with
832 additions
and
308 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
//class Channel { | ||
// send(ByteData message) -> Future | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'package:flutter/services.dart'; | ||
import '../client.dart'; | ||
import 'message_matcher.dart'; | ||
|
||
class ChannelClient extends Client { | ||
final MethodChannel _channel; | ||
final _messageMatcher = MessageMatcher(); | ||
|
||
ChannelClient(String channelName) : _channel = MethodChannel(channelName) { | ||
_channel.setMethodCallHandler(_handleMethodCall); | ||
} | ||
|
||
Future<void> initialize() async { | ||
await _messageMatcher.sendAndAwaitResponse("", {}, (Uint8List message) async { | ||
await _channel.invokeMethod("initialize", message); | ||
}); | ||
} | ||
|
||
@override | ||
Future<T> invoke<T>(String method, [Object? args]) async { | ||
return await _messageMatcher.sendAndAwaitResponse(method, args, (Uint8List message) async { | ||
await _channel.invokeMethod("invoke", message); | ||
}); | ||
} | ||
|
||
@override | ||
Future<void> close() async { | ||
_channel.setMethodCallHandler(null); | ||
_messageMatcher.close(); | ||
} | ||
|
||
Future<dynamic> _handleMethodCall(MethodCall call) async { | ||
final args = (call.arguments as List<Object?>).cast<int>(); | ||
_messageMatcher.handleResponse(Uint8List.fromList(args)); | ||
return null; | ||
} | ||
|
||
@override | ||
Subscriptions subscriptions() => _messageMatcher.subscriptions(); | ||
} |
Oops, something went wrong.