connect method
Implementation
@override
Future<bool> connect(
String address, String type, bool isCloseConnection, int timeout) async {
try {
final version =
await methodChannel.invokeMethod('connect', <String, dynamic>{
'address': address,
'type': type,
'isCloseConnection': isCloseConnection,
}).timeout(
Duration(seconds: timeout ?? 30), // กำหนด Timeout 5 นาที
onTimeout: () {
throw TimeoutException("Method timed out after 5 minutes.");
},
);
return version;
} on TimeoutException catch (e) {
return false;
} catch (e) {
return false;
}
}