connect method

  1. @override
Future<bool> connect(
  1. String address,
  2. String type,
  3. bool isCloseConnection,
  4. int timeout,
)
override

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;
  }
}