4
2
Fork 0

feat: integrating into methodchannel interface

pull/43/head
Sudharshan S. 2019-05-12 09:06:16 +08:00
parent 056eed8c70
commit be0f9e2051
Signed by: sudharshan
GPG Key ID: C861C97AAF3D9559
2 changed files with 15 additions and 7 deletions

View File

@ -9,22 +9,30 @@ import Flutter
) -> Bool {
let controller: FlutterViewController = window?.rootViewController as! FlutterViewController
let conversationChannel = FlutterMethodChannel(name: "beepvoice.app/conversation", binaryMessenger: controller)
let peerManager = PeerManager()
conversationChannel.setMethodCallHandler({
(call: FlutterMethodCall, result: FlutterResult) -> Void in
switch call.method {
case "join":
print("Join executed")
result(String(""))
if let conversationId: String = call.arguments as? String {
peerManager.join(conversationId: conversationId)
print("Join executed")
}
return
case "exit":
print("exit executed")
result(String(""))
peerManager.exit()
print("Exit executed")
return
case "get":
if let activeConversation = peerManager.get() {
result(activeConversation)
} else {
result("")
}
print("get executed")
result(String("c-d73b6afa2fe3685faad28eba36d8cd0a"))
return
default:
result(FlutterMethodNotImplemented)
return

View File

@ -6,7 +6,7 @@ class ConversationManager {
Future<int> join(String conversationId) async {
try {
await channel.invokeMethod('join', {"conversationId": conversationId});
await channel.invokeMethod('join', conversationId);
} on PlatformException catch (e) {
print(e);
return -1;
@ -29,7 +29,7 @@ class ConversationManager {
Future<String> get() async {
try {
final String conversationId = await channel.invokeMethod('get');
return "";
return conversationId;
} on PlatformException catch (e) {
print(e);
return "";